mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 06:07:21 +01:00
Pull out gear into separate modules
This commit is contained in:
@@ -1,54 +1,44 @@
|
||||
import {
|
||||
expectValidTranslationString,
|
||||
describeEachItem
|
||||
} from '../helpers/content.helper';
|
||||
import {each} from 'lodash';
|
||||
import { each } from 'lodash';
|
||||
|
||||
import {tree as allGear} from '../../common/script/src/content/gear';
|
||||
import { tree as allGear } from '../../common/script/content/gear';
|
||||
|
||||
describe('Gear', () => {
|
||||
each(allGear, (piece, type) => {
|
||||
describeEachItem(type, piece, (set, key) => {
|
||||
checkGearAttributes(set);
|
||||
each(allGear, (piece, gearType) => {
|
||||
describe(gearType, () => {
|
||||
each(piece, (items, klass) => {
|
||||
context(`${klass} ${gearType}s`, () => {
|
||||
it('have a value of at least 0 for each stat', () => {
|
||||
each(items, (gear, itemKey) => {
|
||||
expect(gear.con).to.be.at.least(0);
|
||||
expect(gear.int).to.be.at.least(0);
|
||||
expect(gear.per).to.be.at.least(0);
|
||||
expect(gear.str).to.be.at.least(0);
|
||||
});
|
||||
});
|
||||
|
||||
it('have a purchase value of at least 0', () => {
|
||||
each(items, (gear, itemKey) => {
|
||||
expect(gear.value).to.be.at.least(0);
|
||||
});
|
||||
});
|
||||
|
||||
it('has a canBuy function', () => {
|
||||
each(items, (gear, itemKey) => {
|
||||
expect(gear.canBuy).to.be.a('function');
|
||||
});
|
||||
});
|
||||
|
||||
it('have valid translation strings for text and notes', () => {
|
||||
each(items, (gear, itemKey) => {
|
||||
expectValidTranslationString(gear.text);
|
||||
expectValidTranslationString(gear.notes);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function checkGearAttributes(set) {
|
||||
each(set, (gear, key) => {
|
||||
describe(`${key}`, () => {
|
||||
|
||||
it('has a value attribute', () => {
|
||||
expect(gear.value).to.be.at.least(0);
|
||||
});
|
||||
|
||||
it('has a valid con attribute', () => {
|
||||
expect(gear.con).to.be.at.least(0);
|
||||
});
|
||||
|
||||
it('has a valid int attribute', () => {
|
||||
expect(gear.int).to.be.at.least(0);
|
||||
});
|
||||
|
||||
it('has a valid per attribute', () => {
|
||||
expect(gear.per).to.be.at.least(0);
|
||||
});
|
||||
|
||||
it('has a valid str attribute', () => {
|
||||
expect(gear.str).to.be.at.least(0);
|
||||
});
|
||||
|
||||
it('has a canBuy function', () => {
|
||||
expect(gear.canBuy).to.be.a('function');
|
||||
});
|
||||
|
||||
it('has a valid text attribute', () => {
|
||||
expectValidTranslationString(gear.text);
|
||||
});
|
||||
|
||||
it('has a valid notes attribute', () => {
|
||||
expectValidTranslationString(gear.notes);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user