chore(tests): Add test to catch bugs when adding invalid types to market
This commit is contained in:
@@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user