v3: port hatch, equip and feed ops

This commit is contained in:
Matteo Pagliazzi
2016-03-24 16:08:58 +01:00
parent 23f92e2d28
commit 0a65e6a6f1
15 changed files with 783 additions and 336 deletions
@@ -0,0 +1,42 @@
/* eslint-disable camelcase */
import {
generateUser,
} from '../../../../helpers/api-integration/v3';
describe('POST /user/equip/:type/:key', () => {
let user;
beforeEach(async () => {
user = await generateUser();
});
// More tests in common code unit tests
it('equip an item', async () => {
await user.update({
'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,
},
'items.gear.equipped': {
weapon: 'weapon_warrior_0',
shield: 'shield_base_0',
},
'stats.gp': 200,
});
await user.post(`/user/equip/equipped/weapon_warrior_1`);
let res = await user.post(`/user/equip/equipped/weapon_warrior_2`);
await user.sync();
expect(res).to.eql({
data: JSON.parse(JSON.stringify(user.items)),
});
});
});
@@ -0,0 +1,45 @@
/* eslint-disable camelcase */
import {
generateUser,
translate as t,
} from '../../../../helpers/api-integration/v3';
import content from '../../../../../common/script/content';
describe('POST /user/feed/:pet/:food', () => {
let user;
beforeEach(async () => {
user = await generateUser();
});
// More tests in common code unit tests
it('does not enjoy the food', async () => {
await user.update({
'items.pets.Wolf-Base': 5,
'items.food.Milk': 2,
});
let food = content.food.Milk;
let [egg, potion] = 'Wolf-Base'.split('-');
let potionText = content.hatchingPotions[potion] ? content.hatchingPotions[potion].text() : potion;
let eggText = content.eggs[egg] ? content.eggs[egg].text() : egg;
let res = await user.post(`/user/feed/Wolf-Base/Milk`);
await user.sync();
expect(res).to.eql({
data: user.items.pets['Wolf-Base'],
message: t('messageDontEnjoyFood', {
egg: t('petName', {
potion: potionText,
egg: eggText,
}),
foodText: food.text(),
}),
});
expect(user.items.food.Milk).to.equal(1);
expect(user.items.pets['Wolf-Base']).to.equal(7);
});
});
@@ -0,0 +1,31 @@
import {
generateUser,
translate as t,
} from '../../../../helpers/api-integration/v3';
describe('POST /user/hatch/:egg/:hatchingPotion', () => {
let user;
beforeEach(async () => {
user = await generateUser();
});
// More tests in common code unit tests
it('hatch a new pet', async () => {
await user.update({
'items.eggs.Wolf': 1,
'items.hatchingPotions.Base': 1,
});
let res = await user.post(`/user/hatch/Wolf/Base`);
await user.sync();
expect(user.items.pets['Wolf-Base']).to.equal(5);
expect(user.items.eggs.Wolf).to.equal(0);
expect(user.items.hatchingPotions.Base).to.equal(0);
expect(res).to.eql({
message: t('messageHatched'),
data: JSON.parse(JSON.stringify(user.items)),
});
});
});
+85
View 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,
});
});
});
});
+219
View File
@@ -0,0 +1,219 @@
import feed from '../../../common/script/ops/feed';
import content from '../../../common/script/content';
import {
BadRequest,
NotAuthorized,
NotFound,
} from '../../../common/script/libs/errors';
import i18n from '../../../common/script/i18n';
import {
generateUser,
} from '../../helpers/common.helper';
describe('shared.ops.feed', () => {
let user;
beforeEach(() => {
user = generateUser();
});
context('failure conditions', () => {
it('does not allow feeding without specifying pet and food', () => {
try {
feed(user);
} catch (err) {
expect(err).to.be.an.instanceof(BadRequest);
expect(err.message).to.equal(i18n.t('missingPetFoodFeed'));
}
});
it('does not allow feeding if pet name format is invalid', () => {
try {
feed(user, {params: {pet: 'invalid', food: 'food'}});
} catch (err) {
expect(err).to.be.an.instanceof(BadRequest);
expect(err.message).to.equal(i18n.t('invalidPetName'));
}
});
it('does not allow feeding if food does not exists', () => {
try {
feed(user, {params: {pet: 'valid-pet', food: 'invalid food name'}});
} catch (err) {
expect(err).to.be.an.instanceof(NotFound);
expect(err.message).to.equal(i18n.t('messageFoodNotFound'));
}
});
it('does not allow feeding if pet is not owned', () => {
try {
feed(user, {params: {pet: 'not-owned', food: 'Meat'}});
} catch (err) {
expect(err).to.be.an.instanceof(NotFound);
expect(err.message).to.equal(i18n.t('messagePetNotFound'));
}
});
it('does not allow feeding if food is not owned', () => {
user.items.pets['Wolf-Base'] = 5;
try {
feed(user, {params: {pet: 'Wolf-Base', food: 'Meat'}});
} catch (err) {
expect(err).to.be.an.instanceof(NotFound);
expect(err.message).to.equal(i18n.t('messageFoodNotFound'));
}
});
it('does not allow feeding of special pets', () => {
user.items.pets['Wolf-Veteran'] = 5;
user.items.food.Meat = 1;
try {
feed(user, {params: {pet: 'Wolf-Veteran', food: 'Meat'}});
} catch (err) {
expect(err).to.be.an.instanceof(NotAuthorized);
expect(err.message).to.equal(i18n.t('messageCannotFeedPet'));
}
});
it('does not allow feeding of mounts', () => {
user.items.pets['Wolf-Base'] = -1;
user.items.mounts['Wolf-Base'] = true;
user.items.food.Meat = 1;
try {
feed(user, {params: {pet: 'Wolf-Base', food: 'Meat'}});
} catch (err) {
expect(err).to.be.an.instanceof(NotAuthorized);
expect(err.message).to.equal(i18n.t('messageAlreadyMount'));
}
});
});
context('successful feeding', () => {
it('evolves the pet if the food is a Saddle', () => {
user.items.pets['Wolf-Base'] = 5;
user.items.food.Saddle = 2;
user.items.currentPet = 'Wolf-Base';
let [egg, potion] = 'Wolf-Base'.split('-');
let potionText = content.hatchingPotions[potion] ? content.hatchingPotions[potion].text() : potion;
let eggText = content.eggs[egg] ? content.eggs[egg].text() : egg;
let res = feed(user, {params: {pet: 'Wolf-Base', food: 'Saddle'}});
expect(res).to.eql({
data: user.items.pets['Wolf-Base'],
message: i18n.t('messageEvolve', {
egg: i18n.t('petName', {
potion: potionText,
egg: eggText,
}),
}),
});
expect(user.items.food.Saddle).to.equal(1);
expect(user.items.pets['Wolf-Base']).to.equal(-1);
expect(user.items.mounts['Wolf-Base']).to.equal(true);
expect(user.items.currentPet).to.equal('');
});
it('enjoys the food', () => {
user.items.pets['Wolf-Base'] = 5;
user.items.food.Meat = 2;
let food = content.food.Meat;
let [egg, potion] = 'Wolf-Base'.split('-');
let potionText = content.hatchingPotions[potion] ? content.hatchingPotions[potion].text() : potion;
let eggText = content.eggs[egg] ? content.eggs[egg].text() : egg;
let res = feed(user, {params: {pet: 'Wolf-Base', food: 'Meat'}});
expect(res).to.eql({
data: user.items.pets['Wolf-Base'],
message: i18n.t('messageLikesFood', {
egg: i18n.t('petName', {
potion: potionText,
egg: eggText,
}),
foodText: food.text(),
}),
});
expect(user.items.food.Meat).to.equal(1);
expect(user.items.pets['Wolf-Base']).to.equal(10);
});
it('enjoys the food (premium potion)', () => {
user.items.pets['Wolf-Spooky'] = 5;
user.items.food.Milk = 2;
let food = content.food.Milk;
let [egg, potion] = 'Wolf-Spooky'.split('-');
let potionText = content.hatchingPotions[potion] ? content.hatchingPotions[potion].text() : potion;
let eggText = content.eggs[egg] ? content.eggs[egg].text() : egg;
let res = feed(user, {params: {pet: 'Wolf-Spooky', food: 'Milk'}});
expect(res).to.eql({
data: user.items.pets['Wolf-Spooky'],
message: i18n.t('messageLikesFood', {
egg: i18n.t('petName', {
potion: potionText,
egg: eggText,
}),
foodText: food.text(),
}),
});
expect(user.items.food.Milk).to.equal(1);
expect(user.items.pets['Wolf-Spooky']).to.equal(10);
});
it('does not like the food', () => {
user.items.pets['Wolf-Base'] = 5;
user.items.food.Milk = 2;
let food = content.food.Milk;
let [egg, potion] = 'Wolf-Base'.split('-');
let potionText = content.hatchingPotions[potion] ? content.hatchingPotions[potion].text() : potion;
let eggText = content.eggs[egg] ? content.eggs[egg].text() : egg;
let res = feed(user, {params: {pet: 'Wolf-Base', food: 'Milk'}});
expect(res).to.eql({
data: user.items.pets['Wolf-Base'],
message: i18n.t('messageDontEnjoyFood', {
egg: i18n.t('petName', {
potion: potionText,
egg: eggText,
}),
foodText: food.text(),
}),
});
expect(user.items.food.Milk).to.equal(1);
expect(user.items.pets['Wolf-Base']).to.equal(7);
});
it('evolves the pet into a mount when feeding user.items.pets[pet] >= 50', () => {
user.items.pets['Wolf-Base'] = 49;
user.items.food.Milk = 2;
user.items.currentPet = 'Wolf-Base';
let [egg, potion] = 'Wolf-Base'.split('-');
let potionText = content.hatchingPotions[potion] ? content.hatchingPotions[potion].text() : potion;
let eggText = content.eggs[egg] ? content.eggs[egg].text() : egg;
let res = feed(user, {params: {pet: 'Wolf-Base', food: 'Milk'}});
expect(res).to.eql({
data: user.items.pets['Wolf-Base'],
message: i18n.t('messageEvolve', {
egg: i18n.t('petName', {
potion: potionText,
egg: eggText,
}),
}),
});
expect(user.items.food.Milk).to.equal(1);
expect(user.items.pets['Wolf-Base']).to.equal(-1);
expect(user.items.mounts['Wolf-Base']).to.equal(true);
expect(user.items.currentPet).to.equal('');
});
});
});
+143
View File
@@ -0,0 +1,143 @@
import hatch from '../../../common/script/ops/hatch';
import {
BadRequest,
NotAuthorized,
NotFound,
} from '../../../common/script/libs/errors';
import i18n from '../../../common/script/i18n';
import {
generateUser,
} from '../../helpers/common.helper';
describe('shared.ops.hatch', () => {
let user;
beforeEach(() => {
user = generateUser();
});
context('Pet Hatching', () => {
context('failure conditions', () => {
it('does not allow hatching without specifying egg and potion', () => {
user.items.pets = {};
try {
hatch(user);
} catch (err) {
expect(err).to.be.an.instanceof(BadRequest);
expect(err.message).to.equal(i18n.t('missingEggHatchingPotionHatch'));
expect(user.items.pets).to.be.empty;
}
});
it('does not allow hatching if user lacks specified egg', () => {
user.items.eggs.Wolf = 1;
user.items.hatchingPotions.Base = 1;
user.items.pets = {};
try {
hatch(user, {params: {egg: 'Dragon', hatchingPotion: 'Base'}});
} catch (err) {
expect(err).to.be.an.instanceof(NotFound);
expect(err.message).to.equal(i18n.t('messageMissingEggPotion'));
expect(user.items.pets).to.be.empty;
expect(user.items.eggs.Wolf).to.equal(1);
expect(user.items.hatchingPotions.Base).to.equal(1);
}
});
it('does not allow hatching if user lacks specified hatching potion', () => {
user.items.eggs.Wolf = 1;
user.items.hatchingPotions.Base = 1;
user.items.pets = {};
try {
hatch(user, {params: {egg: 'Wolf', hatchingPotion: 'Golden'}});
} catch (err) {
expect(err).to.be.an.instanceof(NotFound);
expect(err.message).to.equal(i18n.t('messageMissingEggPotion'));
expect(user.items.pets).to.be.empty;
expect(user.items.eggs.Wolf).to.equal(1);
expect(user.items.hatchingPotions.Base).to.equal(1);
}
});
it('does not allow hatching if user already owns target pet', () => {
user.items.eggs = {Wolf: 1};
user.items.hatchingPotions = {Base: 1};
user.items.pets = {'Wolf-Base': 10};
try {
hatch(user, {params: {egg: 'Wolf', hatchingPotion: 'Base'}});
} catch (err) {
expect(err).to.be.an.instanceof(NotAuthorized);
expect(err.message).to.equal(i18n.t('messageAlreadyPet'));
expect(user.items.pets).to.eql({'Wolf-Base': 10});
expect(user.items.eggs).to.eql({Wolf: 1});
expect(user.items.hatchingPotions).to.eql({Base: 1});
}
});
it('does not allow hatching quest pet egg using premium potion', () => {
user.items.eggs = {Cheetah: 1};
user.items.hatchingPotions = {Spooky: 1};
user.items.pets = {};
try {
hatch(user, {params: {egg: 'Cheetah', hatchingPotion: 'Spooky'}});
} catch (err) {
expect(err).to.be.an.instanceof(BadRequest);
expect(err.message).to.equal(i18n.t('messageInvalidEggPotionCombo'));
expect(user.items.pets).to.be.empty;
expect(user.items.eggs).to.eql({Cheetah: 1});
expect(user.items.hatchingPotions).to.eql({Spooky: 1});
}
});
});
context('successful hatching', () => {
it('hatches a basic pet', () => {
user.items.eggs = {Wolf: 1};
user.items.hatchingPotions = {Base: 1};
user.items.pets = {};
let res = hatch(user, {params: {egg: 'Wolf', hatchingPotion: 'Base'}});
expect(res.message).to.equal(i18n.t('messageHatched'));
expect(res.data).to.eql(user.items);
expect(user.items.pets).to.eql({'Wolf-Base': 5});
expect(user.items.eggs).to.eql({Wolf: 0});
expect(user.items.hatchingPotions).to.eql({Base: 0});
});
it('hatches a quest pet', () => {
user.items.eggs = {Cheetah: 1};
user.items.hatchingPotions = {Base: 1};
user.items.pets = {};
let res = hatch(user, {params: {egg: 'Cheetah', hatchingPotion: 'Base'}});
expect(res.message).to.equal(i18n.t('messageHatched'));
expect(res.data).to.eql(user.items);
expect(user.items.pets).to.eql({'Cheetah-Base': 5});
expect(user.items.eggs).to.eql({Cheetah: 0});
expect(user.items.hatchingPotions).to.eql({Base: 0});
});
it('hatches a premium pet', () => {
user.items.eggs = {Wolf: 1};
user.items.hatchingPotions = {Spooky: 1};
user.items.pets = {};
let res = hatch(user, {params: {egg: 'Wolf', hatchingPotion: 'Spooky'}});
expect(res.message).to.equal(i18n.t('messageHatched'));
expect(res.data).to.eql(user.items);
expect(user.items.pets).to.eql({'Wolf-Spooky': 5});
expect(user.items.eggs).to.eql({Wolf: 0});
expect(user.items.hatchingPotions).to.eql({Spooky: 0});
});
it('hatches a pet previously raised to a mount', () => {
user.items.eggs = {Wolf: 1};
user.items.hatchingPotions = {Base: 1};
user.items.pets = {'Wolf-Base': -1};
let res = hatch(user, {params: {egg: 'Wolf', hatchingPotion: 'Base'}});
expect(res.message).to.eql(i18n.t('messageHatched'));
expect(res.data).to.eql(user.items);
expect(user.items.pets).to.eql({'Wolf-Base': 5});
expect(user.items.eggs).to.eql({Wolf: 0});
expect(user.items.hatchingPotions).to.eql({Base: 0});
});
});
});
});
-102
View File
@@ -1,102 +0,0 @@
/* eslint-disable camelcase */
import sinon from 'sinon'; // eslint-disable-line no-shadow
import {assert} from 'sinon';
import i18n from '../../common/script/i18n';
import shared from '../../common/script/index.js';
import content from '../../common/script/content/index';
describe('user.ops.equip', () => {
let user;
let spy;
beforeEach(() => {
user = {
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',
},
},
},
preferences: {},
stats: {gp: 200},
achievements: {},
flags: {},
};
shared.wrap(user);
spy = sinon.spy();
});
context('Gear', () => {
it('should not send a message if a weapon is equipped while only having zero or one weapons equipped', () => {
// user.ops.equip always calls the callback, even if it isn't sending a message
// so we need to check to see if a single null message was sent.
user.ops.equip({params: {key: 'weapon_warrior_1'}});
// one-handed to one-handed
user.ops.equip({params: {key: 'weapon_warrior_2'}}, spy);
assert.calledOnce(spy);
assert.calledWith(spy, null);
spy.reset();
// one-handed to two-handed
user.ops.equip({params: {key: 'weapon_wizard_1'}}, spy);
assert.calledOnce(spy);
assert.calledWith(spy, null);
spy.reset();
// two-handed to two-handed
user.ops.equip({params: {key: 'weapon_wizard_2'}}, spy);
assert.calledOnce(spy);
assert.calledWith(spy, null);
spy.reset();
// two-handed to one-handed
user.ops.equip({params: {key: 'weapon_warrior_2'}}, spy);
assert.calledOnce(spy);
assert.calledWith(spy, null);
spy.reset();
});
it('should send messages if equipping a two-hander causes the off-hander to be unequipped', () => {
user.ops.equip({params: {key: 'weapon_warrior_1'}});
user.ops.equip({params: {key: 'shield_warrior_1'}});
// equipping two-hander
user.ops.equip({params: {key: 'weapon_wizard_1'}}, spy);
let weapon = content.gear.flat.weapon_wizard_1;
let item = content.gear.flat.shield_warrior_1;
let message = i18n.t('messageTwoHandedEquip', {twoHandedText: weapon.text(null), offHandedText: item.text(null)});
assert.calledOnce(spy);
assert.calledWith(spy, {code: 200, message});
});
it('should send messages if equipping an off-hand item causes a two-handed weapon to be unequipped', () => {
// equipping two-hander
user.ops.equip({params: {key: 'weapon_wizard_1'}});
let weapon = content.gear.flat.weapon_wizard_1;
let shield = content.gear.flat.shield_warrior_1;
user.ops.equip({params: {key: 'shield_warrior_1'}}, spy);
let message = i18n.t('messageTwoHandedUnequip', {twoHandedText: weapon.text(null), offHandedText: shield.text(null)});
assert.calledOnce(spy);
assert.calledWith(spy, {code: 200, message});
});
});
});
-129
View File
@@ -1,129 +0,0 @@
let shared = require('../../common/script/index.js');
describe('user.ops.hatch', () => {
let user;
beforeEach(() => {
user = {
items: {
eggs: {},
hatchingPotions: {},
pets: {},
},
};
shared.wrap(user);
});
context('Pet Hatching', () => {
context('failure conditions', () => {
it('does not allow hatching without specifying egg and potion', (done) => {
user.ops.hatch({params: {}}, (response) => {
expect(response.message).to.eql('Please specify query.egg & query.hatchingPotion');
expect(user.items.pets).to.be.empty;
done();
});
});
it('does not allow hatching if user lacks specified egg', (done) => {
user.items.eggs = {Wolf: 1};
user.items.hatchingPotions = {Base: 1};
user.ops.hatch({params: {egg: 'Dragon', hatchingPotion: 'Base'}}, (response) => {
expect(response.message).to.eql(shared.i18n.t('messageMissingEggPotion'));
expect(user.items.pets).to.be.empty;
expect(user.items.eggs).to.eql({Wolf: 1});
expect(user.items.hatchingPotions).to.eql({Base: 1});
done();
});
});
it('does not allow hatching if user lacks specified hatching potion', (done) => {
user.items.eggs = {Wolf: 1};
user.items.hatchingPotions = {Base: 1};
user.ops.hatch({params: {egg: 'Wolf', hatchingPotion: 'Golden'}}, (response) => {
expect(response.message).to.eql(shared.i18n.t('messageMissingEggPotion'));
expect(user.items.pets).to.be.empty;
expect(user.items.eggs).to.eql({Wolf: 1});
expect(user.items.hatchingPotions).to.eql({Base: 1});
done();
});
});
it('does not allow hatching if user already owns target pet', (done) => {
user.items.eggs = {Wolf: 1};
user.items.hatchingPotions = {Base: 1};
user.items.pets = {'Wolf-Base': 10};
user.ops.hatch({params: {egg: 'Wolf', hatchingPotion: 'Base'}}, (response) => {
expect(response.message).to.eql(shared.i18n.t('messageAlreadyPet'));
expect(user.items.pets).to.eql({'Wolf-Base': 10});
expect(user.items.eggs).to.eql({Wolf: 1});
expect(user.items.hatchingPotions).to.eql({Base: 1});
done();
});
});
it('does not allow hatching quest pet egg using premium potion', (done) => {
user.items.eggs = {Cheetah: 1};
user.items.hatchingPotions = {Spooky: 1};
user.ops.hatch({params: {egg: 'Cheetah', hatchingPotion: 'Spooky'}}, (response) => {
expect(response.message).to.eql(shared.i18n.t('messageInvalidEggPotionCombo'));
expect(user.items.pets).to.be.empty;
expect(user.items.eggs).to.eql({Cheetah: 1});
expect(user.items.hatchingPotions).to.eql({Spooky: 1});
done();
});
});
});
context('successful hatching', () => {
it('hatches a basic pet', (done) => {
user.items.eggs = {Wolf: 1};
user.items.hatchingPotions = {Base: 1};
user.ops.hatch({params: {egg: 'Wolf', hatchingPotion: 'Base'}}, (response) => {
expect(response.message).to.eql(shared.i18n.t('messageHatched'));
expect(user.items.pets).to.eql({'Wolf-Base': 5});
expect(user.items.eggs).to.eql({Wolf: 0});
expect(user.items.hatchingPotions).to.eql({Base: 0});
done();
});
});
it('hatches a quest pet', (done) => {
user.items.eggs = {Cheetah: 1};
user.items.hatchingPotions = {Base: 1};
user.ops.hatch({params: {egg: 'Cheetah', hatchingPotion: 'Base'}}, (response) => {
expect(response.message).to.eql(shared.i18n.t('messageHatched'));
expect(user.items.pets).to.eql({'Cheetah-Base': 5});
expect(user.items.eggs).to.eql({Cheetah: 0});
expect(user.items.hatchingPotions).to.eql({Base: 0});
done();
});
});
it('hatches a premium pet', (done) => {
user.items.eggs = {Wolf: 1};
user.items.hatchingPotions = {Spooky: 1};
user.ops.hatch({params: {egg: 'Wolf', hatchingPotion: 'Spooky'}}, (response) => {
expect(response.message).to.eql(shared.i18n.t('messageHatched'));
expect(user.items.pets).to.eql({'Wolf-Spooky': 5});
expect(user.items.eggs).to.eql({Wolf: 0});
expect(user.items.hatchingPotions).to.eql({Spooky: 0});
done();
});
});
it('hatches a pet previously raised to a mount', (done) => {
user.items.eggs = {Wolf: 1};
user.items.hatchingPotions = {Base: 1};
user.items.pets = {'Wolf-Base': -1};
user.ops.hatch({params: {egg: 'Wolf', hatchingPotion: 'Base'}}, (response) => {
expect(response.message).to.eql(shared.i18n.t('messageHatched'));
expect(user.items.pets).to.eql({'Wolf-Base': 5});
expect(user.items.eggs).to.eql({Wolf: 0});
expect(user.items.hatchingPotions).to.eql({Base: 0});
done();
});
});
});
});
});