chore(tests): Add test to catch bugs when adding invalid types to market

This commit is contained in:
Blade Barringer 2016-08-10 08:43:27 -05:00
parent 64ffa4912d
commit 384783567b

View file

@ -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');
});
});
});