mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Add API calls for shop inventories (#7810)
* Add API call for market inventory * changes to shop api calls * optimize shop categories * add API call for quests * add api call for time travelers shop * fic buying items in shops * fix linting errors * shop adjustments for iOS app * add tests to shops * fix syntax issues * Code formatting * correct indentation * add tests for api routes * fix time travelers and seasonal * Increase test coverage for shop routes * refactor: Pull out trinket count in time traveler route * refactor: Clarify instructions for seasonal shop script * lint: Remove extra new line * Adjust shops common test
This commit is contained in:
committed by
Sabe Jones
parent
aa00893f6c
commit
24d25026cf
84
test/common/libs/shops.js
Normal file
84
test/common/libs/shops.js
Normal file
@@ -0,0 +1,84 @@
|
||||
import shared from '../../../common';
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../helpers/common.helper';
|
||||
|
||||
describe('shops', () => {
|
||||
let user = generateUser();
|
||||
|
||||
describe('market', () => {
|
||||
let shopCategories = shared.shops.getMarketCategories(user);
|
||||
|
||||
it('contains at least the 3 default categories', () => {
|
||||
expect(shopCategories.length).to.be.greaterThan(2);
|
||||
});
|
||||
|
||||
it('does not contain an empty category', () => {
|
||||
_.each(shopCategories, (category) => {
|
||||
expect(category.items.length).to.be.greaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
it('items contain required fields', () => {
|
||||
_.each(shopCategories, (category) => {
|
||||
_.each(category.items, (item) => {
|
||||
expect(item).to.have.all.keys(['key', 'text', 'notes', 'value', 'currency', 'locked', 'purchaseType', 'class']);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('questShop', () => {
|
||||
let shopCategories = shared.shops.getQuestShopCategories(user);
|
||||
|
||||
it('does not contain an empty category', () => {
|
||||
_.each(shopCategories, (category) => {
|
||||
expect(category.items.length).to.be.greaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
it('items contain required fields', () => {
|
||||
_.each(shopCategories, (category) => {
|
||||
_.each(category.items, (item) => {
|
||||
expect(item).to.have.all.keys('key', 'text', 'notes', 'value', 'currency', 'locked', 'purchaseType', 'boss', 'class', 'collect', 'drop', 'unlockCondition', 'lvl');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('timeTravelers', () => {
|
||||
let shopCategories = shared.shops.getTimeTravelersCategories(user);
|
||||
|
||||
it('does not contain an empty category', () => {
|
||||
_.each(shopCategories, (category) => {
|
||||
expect(category.items.length).to.be.greaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
it('items contain required fields', () => {
|
||||
_.each(shopCategories, (category) => {
|
||||
_.each(category.items, (item) => {
|
||||
expect(item).to.have.all.keys('key', 'text', 'value', 'currency', 'locked', 'purchaseType', 'class', 'notes', 'class');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('seasonalShop', () => {
|
||||
let shopCategories = shared.shops.getSeasonalShopCategories(user);
|
||||
|
||||
it('does not contain an empty category', () => {
|
||||
_.each(shopCategories, (category) => {
|
||||
expect(category.items.length).to.be.greaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
it('items contain required fields', () => {
|
||||
_.each(shopCategories, (category) => {
|
||||
_.each(category.items, (item) => {
|
||||
expect(item).to.have.all.keys('key', 'text', 'notes', 'value', 'currency', 'locked', 'purchaseType', 'specialClass', 'type');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user