wip: fix setting (some) items values in the hall of heroes (#11133)

This commit is contained in:
Matteo Pagliazzi
2019-04-25 22:41:43 +02:00
committed by GitHub
parent 99dec2eb0c
commit 9d473cc92e
3 changed files with 71 additions and 2 deletions
+46
View File
@@ -2,6 +2,7 @@
import {
validateItemPath,
getDefaultOwnedGear,
castItemVal,
} from '../../../../../website/server/libs/items/utils';
describe('Items Utils', () => {
@@ -64,4 +65,49 @@ describe('Items Utils', () => {
expect(validateItemPath('items.quests.invalid')).to.equal(false);
});
});
describe('castItemVal', () => {
it('returns the item val untouched if not an item path', () => {
expect(castItemVal('notitems.gear.owned.item', 'a string')).to.equal('a string');
});
it('returns the item val untouched if an unsupported path', () => {
expect(validateItemPath('items.gear.equipped.weapon', 'a string')).to.equal('a string');
expect(validateItemPath('items.currentPet', 'a string')).to.equal('a string');
expect(validateItemPath('items.special.snowball', 'a string')).to.equal('a string');
});
it('converts values for pets paths to numbers', () => {
expect(validateItemPath('items.pets.Wolf-CottonCandyPink', '5')).to.equal(5);
expect(validateItemPath('items.pets.Wolf-Invalid', '5')).to.equal(5);
});
it('converts values for eggs paths to numbers', () => {
expect(validateItemPath('items.eggs.LionCub', '5')).to.equal(5);
expect(validateItemPath('items.eggs.Armadillo', '5')).to.equal(5);
expect(validateItemPath('items.eggs.NotAnArmadillo', '5')).to.equal(5);
});
it('converts values for hatching potions paths to numbers', () => {
expect(validateItemPath('items.hatchingPotions.Base', '5')).to.equal(5);
expect(validateItemPath('items.hatchingPotions.StarryNight', '5')).to.equal(5);
expect(validateItemPath('items.hatchingPotions.Invalid', '5')).to.equal(5);
});
it('converts values for food paths to numbers', () => {
expect(validateItemPath('items.food.Cake_Base', '5')).to.equal(5);
expect(validateItemPath('items.food.Cake_Invalid', '5')).to.equal(5);
});
it('converts values for mounts paths to numbers', () => {
expect(validateItemPath('items.mounts.Cactus-Base', '5')).to.equal(5);
expect(validateItemPath('items.mounts.Aether-Invisible', '5')).to.equal(5);
expect(validateItemPath('items.mounts.Aether-Invalid', '5')).to.equal(5);
});
it('converts values for quests paths to numbers', () => {
expect(validateItemPath('items.quests.atom3', '5')).to.equal(5);
expect(validateItemPath('items.quests.invalid', '5')).to.equal(5);
});
});
});