mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
v3: port hatch, equip and feed ops
This commit is contained in:
85
test/common/ops/equip.js
Normal file
85
test/common/ops/equip.js
Normal file
@@ -0,0 +1,85 @@
|
||||
/* eslint-disable camelcase */
|
||||
import equip from '../../../common/script/ops/equip';
|
||||
import i18n from '../../../common/script/i18n';
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../helpers/common.helper';
|
||||
import content from '../../../common/script/content/index';
|
||||
|
||||
describe('shared.ops.equip', () => {
|
||||
let user;
|
||||
|
||||
beforeEach(() => {
|
||||
user = generateUser({
|
||||
items: {
|
||||
gear: {
|
||||
owned: {
|
||||
weapon_warrior_0: true,
|
||||
weapon_warrior_1: true,
|
||||
weapon_warrior_2: true,
|
||||
weapon_wizard_1: true,
|
||||
weapon_wizard_2: true,
|
||||
shield_base_0: true,
|
||||
shield_warrior_1: true,
|
||||
},
|
||||
equipped: {
|
||||
weapon: 'weapon_warrior_0',
|
||||
shield: 'shield_base_0',
|
||||
},
|
||||
},
|
||||
},
|
||||
stats: {gp: 200},
|
||||
});
|
||||
});
|
||||
|
||||
context('Gear', () => {
|
||||
it('should not send a message if a weapon is equipped while only having zero or one weapons equipped', () => {
|
||||
equip(user, {params: {key: 'weapon_warrior_1'}});
|
||||
|
||||
// one-handed to one-handed
|
||||
let res = equip(user, {params: {key: 'weapon_warrior_2'}});
|
||||
expect(res.message).to.not.exists;
|
||||
|
||||
// one-handed to two-handed
|
||||
res = equip(user, {params: {key: 'weapon_wizard_1'}});
|
||||
expect(res.message).to.not.exists;
|
||||
|
||||
// two-handed to two-handed
|
||||
res = equip(user, {params: {key: 'weapon_wizard_2'}});
|
||||
expect(res.message).to.not.exists;
|
||||
|
||||
// two-handed to one-handed
|
||||
res = equip(user, {params: {key: 'weapon_warrior_2'}});
|
||||
expect(res.message).to.not.exists;
|
||||
});
|
||||
|
||||
it('should send messages if equipping a two-hander causes the off-hander to be unequipped', () => {
|
||||
equip(user, {params: {key: 'weapon_warrior_1'}});
|
||||
equip(user, {params: {key: 'shield_warrior_1'}});
|
||||
|
||||
// equipping two-hander
|
||||
let res = equip(user, {params: {key: 'weapon_wizard_1'}});
|
||||
let weapon = content.gear.flat.weapon_wizard_1;
|
||||
let item = content.gear.flat.shield_warrior_1;
|
||||
|
||||
expect(res).to.eql({
|
||||
message: i18n.t('messageTwoHandedEquip', {twoHandedText: weapon.text(), offHandedText: item.text()}),
|
||||
data: user.items,
|
||||
});
|
||||
});
|
||||
|
||||
it('should send messages if equipping an off-hand item causes a two-handed weapon to be unequipped', () => {
|
||||
// equipping two-hander
|
||||
equip(user, {params: {key: 'weapon_wizard_1'}});
|
||||
let weapon = content.gear.flat.weapon_wizard_1;
|
||||
let shield = content.gear.flat.shield_warrior_1;
|
||||
|
||||
let res = equip(user, {params: {key: 'shield_warrior_1'}});
|
||||
|
||||
expect(res).to.eql({
|
||||
message: i18n.t('messageTwoHandedUnequip', {twoHandedText: weapon.text(), offHandedText: shield.text()}),
|
||||
data: user.items,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user