add tests for fns/ultimateGear, fns/handleTwoHanded, fns/randomVal, fns/predictableRandom and partial tests for ops/buy

This commit is contained in:
Matteo Pagliazzi
2016-03-19 18:05:02 +01:00
parent ff72706cae
commit 957e1d26d6
12 changed files with 341 additions and 137 deletions

View File

@@ -0,0 +1,38 @@
import handleTwoHanded from '../../../common/script/fns/handleTwoHanded';
import content from '../../../common/script/content/index';
import i18n from '../../../common/script/i18n';
import {
generateUser,
} from '../../helpers/common.helper';
describe('shared.fns.handleTwoHanded', () => {
let user;
beforeEach(() => {
user = generateUser();
});
it('uses "messageTwoHandedUnequip" message if item is a shield and current weapon is two handed (and sets the user\'s weapon to the base one)', () => {
let item = content.gear.tree.shield.warrior['2'];
let currentWeapon = content.gear.tree.weapon.armoire.rancherLasso;
user.items.gear.equipped.weapon = 'weapon_armoire_rancherLasso';
let message = handleTwoHanded(user, item);
expect(message).to.equal(i18n.t('messageTwoHandedUnequip', {
twoHandedText: currentWeapon.text(), offHandedText: item.text(),
}));
expect(user.items.gear.equipped.weapon).to.equal('weapon_base_0');
});
it('uses "messageTwoHandedEquip" message if item is two handed and currentShield exists but is not "shield_base_0" (and sets the user\'s shield to the base one)', () => {
let item = content.gear.tree.weapon.armoire.rancherLasso;
let currentShield = content.gear.tree.shield.armoire.gladiatorShield;
user.items.gear.equipped.shield = 'shield_armoire_gladiatorShield';
let message = handleTwoHanded(user, item);
expect(message).to.equal(i18n.t('messageTwoHandedEquip', {
twoHandedText: item.text(), offHandedText: currentShield.text(),
}));
expect(user.items.gear.equipped.shield).to.equal('shield_base_0');
});
});