Pull out gear into separate modules

This commit is contained in:
Blade Barringer
2015-11-16 17:29:13 -06:00
parent 2b8cf178b0
commit 639dfb31d7
29 changed files with 3022 additions and 5567 deletions

View File

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