diff --git a/test/api/v3/integration/shops/GET-shops_market.test.js b/test/api/v3/integration/shops/GET-shops_market.test.js index 02162f0d5c..04a19f8479 100644 --- a/test/api/v3/integration/shops/GET-shops_market.test.js +++ b/test/api/v3/integration/shops/GET-shops_market.test.js @@ -2,6 +2,7 @@ import { generateUser, translate as t, } from '../../../../helpers/api-integration/v3'; +import Bluebird from 'bluebird'; describe('GET /shops/market', () => { let user; @@ -25,4 +26,30 @@ describe('GET /shops/market', () => { expect(categories).to.include('hatchingPotions'); expect(categories).to.include('food'); }); + + it('can purchase anything returned from the shops object using the /user/purchase route', async () => { + await user.update({ + balance: 99999999, + 'stats.gp': 99999999, + }); + + let shop = await user.get('/shops/market'); + let items = shop.categories.reduce((array, category) => { + category.items.forEach((item) => { + array.push(item); + }); + + return array; + }, []); + + let results = await Bluebird.each(items, (item) => { + let { purchaseType, key } = item; + return user.post(`/user/purchase/${purchaseType}/${key}`); + }); + + expect(results.length).to.be.greaterThan(0); + results.forEach((item) => { + expect(item).to.include.keys('key', 'text', 'notes', 'class', 'value', 'currency'); + }); + }); });