Refactor Purchase API - Part 1 (#9714)

* move to shops/purchase

* move files to /buy/ instead of /purchase/

* refactor buy.js - add more itemtypes

* revert moving special purchases to buy

* only use buyOp from api-routes

* fix buying potion client-side

* undo import buy instead of purchase

* enable potion bulk purchase - use buyGear as fallback (as before)

* move quantity purchase inside buyHealthPotion

* move quantity purchase inside buyQuest

* move quantity purchase inside buySpecialSpell + add analytics

* remove unused quantity variable - set req.type on specialKeys

* fix `buyKnownKeys` on buy api

* test buy-special-spell if not enough gold

* more buy ops coverage

* fix lint

* buyMysterySet: test for window.confirm, buyQuest: check for Masterclassers unlock

* fix test & lint

* re-create package-lock.json to travis build ?

* use global.window instead of method argument

* add back canOwn checks

* remove buyMysterySet confirm request
This commit is contained in:
negue
2018-02-10 11:14:40 +01:00
committed by Matteo Pagliazzi
parent 7abfd1d510
commit 54153ec299
27 changed files with 340 additions and 181 deletions
@@ -40,4 +40,19 @@ describe('POST /user/buy-special-spell/:key', () => {
itemText: item.text(),
}));
});
it('returns an error if user does not have enough gold', async () => {
let key = 'thankyou';
await user.update({
'stats.gp': 5,
});
await expect(user.post(`/user/buy-special-spell/${key}`))
.to.eventually.be.rejected.and.eql({
code: 401,
error: 'NotAuthorized',
message: t('messageNotEnoughGold'),
});
});
});