Files
habitica/test/api/v3/integration/user/POST-user_buy_armoire.test.js
T
2016-05-16 14:10:39 -05:00

42 lines
918 B
JavaScript

import {
generateUser,
translate as t,
} from '../../../../helpers/api-integration/v3';
describe('POST /user/buy-armoire', () => {
let user;
beforeEach(async () => {
user = await generateUser({
'stats.gp': 400,
});
});
// More tests in common code unit tests
it('returns an error if user does not have enough gold', async () => {
await user.update({
'stats.gp': 5,
});
await expect(user.post('/user/buy-armoire'))
.to.eventually.be.rejected.and.eql({
code: 401,
error: 'NotAuthorized',
message: t('messageNotEnoughGold'),
});
});
it('reduces gold when buying from the armoire', async () => {
await user.post('/user/buy-armoire');
await user.sync();
expect(user.stats.gp).to.equal(300);
});
xit('buys a piece of armoire', async () => {
// Skipped because can't stub predictableRandom correctly
});
});