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)),
});
});
});