mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-14 16:02:14 +00:00
chore(tests): Add test to catch bugs when adding invalid types to market
This commit is contained in:
parent
64ffa4912d
commit
384783567b
1 changed files with 27 additions and 0 deletions
|
|
@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue