mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Separate out backer gear into own module
This commit is contained in:
@@ -2,8 +2,10 @@ import {
|
||||
expectValidTranslationString,
|
||||
} from '../helpers/content.helper';
|
||||
import { each } from 'lodash';
|
||||
import camelCase from 'lodash.camelcase';
|
||||
|
||||
import { tree as allGear } from '../../common/script/content/gear';
|
||||
import backerGear from '../../common/script/content/gear/sets/special-backer';
|
||||
|
||||
describe('Gear', () => {
|
||||
each(allGear, (piece, gearType) => {
|
||||
@@ -41,4 +43,53 @@ describe('Gear', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('backer gear', () => {
|
||||
let user;
|
||||
|
||||
beforeEach(() => {
|
||||
user = {
|
||||
backer: {},
|
||||
items: { gear: { owned: {} } },
|
||||
};
|
||||
});
|
||||
|
||||
let cases = {
|
||||
armor_special_0: 45,
|
||||
armor_special_2: 300,
|
||||
head_special_0: 45,
|
||||
head_special_2: 300,
|
||||
weapon_special_0: 70,
|
||||
weapon_special_2: 300,
|
||||
weapon_special_3: 300,
|
||||
}
|
||||
|
||||
each(cases, (tierRequirement, key) => {
|
||||
context(key, () => {
|
||||
let camelCaseKey = camelCase(key);
|
||||
|
||||
it(`canOwn returns true if user has a backer tier of ${tierRequirement} or higher`, () => {
|
||||
user.backer.tier = tierRequirement;
|
||||
expect(backerGear[camelCaseKey].canOwn(user)).to.eql(true);
|
||||
|
||||
user.backer.tier = tierRequirement + 1;
|
||||
expect(backerGear[camelCaseKey].canOwn(user)).to.eql(true);
|
||||
});
|
||||
|
||||
it('canOwn returns true if user already owns the item', () => {
|
||||
user.items.gear.owned[key] = true;
|
||||
expect(backerGear[camelCaseKey].canOwn(user)).to.eql(true);
|
||||
});
|
||||
|
||||
it('canOwn returns true if user has previously owned the item', () => {
|
||||
user.items.gear.owned[key] = false;
|
||||
expect(backerGear[camelCaseKey].canOwn(user)).to.eql(true);
|
||||
});
|
||||
|
||||
it('canOwn returns false if user does not have tier requirement and did not previously own the item', () => {
|
||||
expect(backerGear[camelCaseKey].canOwn(user)).to.eql(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user