GP will not be deducted if health is max

This commit is contained in:
Ujjwal Gulecha
2016-08-25 23:25:09 -07:00
parent 320d8cac5f
commit 03c14859d5
4 changed files with 34 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ describe('POST /user/buy/:key', () => {
it('buys a potion', async () => {
await user.update({
'stats.gp': 400,
'stats.hp': 40,
});
let potion = content.potion;
@@ -42,6 +43,19 @@ describe('POST /user/buy/:key', () => {
expect(res.message).to.equal(t('messageBought', {itemText: potion.text()}));
});
it('returns an error if user tries to buy a potion with full health', async () => {
await user.update({
'stats.gp': 40,
'stats.hp': 50,
});
await expect(user.post('/user/buy/potion'))
.to.eventually.be.rejected.and.eql({
code: 401,
error: 'NotAuthorized',
message: t('messageHealthAlreadyMax'),
});
});
it('buys a piece of gear', async () => {
let key = 'armor_warrior_1';