fix test lint
This commit is contained in:
@@ -15,7 +15,7 @@ describe('shared.ops.addTask', () => {
|
||||
});
|
||||
|
||||
it('adds an habit', () => {
|
||||
let habit = addTask(user, {
|
||||
const habit = addTask(user, {
|
||||
body: {
|
||||
type: 'habit',
|
||||
text: 'habit',
|
||||
@@ -39,7 +39,7 @@ describe('shared.ops.addTask', () => {
|
||||
});
|
||||
|
||||
it('adds a habit when type is invalid', () => {
|
||||
let habit = addTask(user, {
|
||||
const habit = addTask(user, {
|
||||
body: {
|
||||
type: 'invalid',
|
||||
text: 'habit',
|
||||
@@ -60,7 +60,7 @@ describe('shared.ops.addTask', () => {
|
||||
});
|
||||
|
||||
it('adds a daily', () => {
|
||||
let daily = addTask(user, {
|
||||
const daily = addTask(user, {
|
||||
body: {
|
||||
type: 'daily',
|
||||
text: 'daily',
|
||||
@@ -80,7 +80,7 @@ describe('shared.ops.addTask', () => {
|
||||
});
|
||||
|
||||
it('adds a todo', () => {
|
||||
let todo = addTask(user, {
|
||||
const todo = addTask(user, {
|
||||
body: {
|
||||
type: 'todo',
|
||||
text: 'todo',
|
||||
@@ -99,7 +99,7 @@ describe('shared.ops.addTask', () => {
|
||||
});
|
||||
|
||||
it('adds a reward', () => {
|
||||
let reward = addTask(user, {
|
||||
const reward = addTask(user, {
|
||||
body: {
|
||||
type: 'reward',
|
||||
text: 'reward',
|
||||
|
||||
@@ -2,8 +2,8 @@ import * as armoireSet from '../../../website/common/script/content/gear/sets/ar
|
||||
|
||||
describe('armoireSet items', () => {
|
||||
it('checks if canOwn has the same id', () => {
|
||||
for (const type of Object.keys(armoireSet)) {
|
||||
for (const itemKey of Object.keys(armoireSet[type])) {
|
||||
Object.keys(armoireSet).forEach(type => {
|
||||
Object.keys(armoireSet[type]).forEach(itemKey => {
|
||||
const ownedKey = `${type}_armoire_${itemKey}`;
|
||||
|
||||
expect(armoireSet[type][itemKey].canOwn({
|
||||
@@ -15,7 +15,7 @@ describe('armoireSet items', () => {
|
||||
},
|
||||
},
|
||||
}), `${ownedKey} canOwn is broken`).to.eq(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@ describe('shared.ops.blockUser', () => {
|
||||
expect(user.inbox.blocks).to.eql([]);
|
||||
});
|
||||
|
||||
it('validates uuid', (done) => {
|
||||
it('validates uuid', done => {
|
||||
try {
|
||||
blockUser(user, { params: { uuid: '1' } });
|
||||
} catch (error) {
|
||||
@@ -25,7 +25,7 @@ describe('shared.ops.blockUser', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('validates user can\'t block himself', (done) => {
|
||||
it('validates user can\'t block himself', done => {
|
||||
try {
|
||||
blockUser(user, { params: { uuid: user._id } });
|
||||
} catch (error) {
|
||||
@@ -46,7 +46,7 @@ describe('shared.ops.blockUser', () => {
|
||||
it('blocks, then unblocks user', () => {
|
||||
blockUser(user, { params: { uuid: blockedUser._id } });
|
||||
expect(user.inbox.blocks).to.eql([blockedUser._id]);
|
||||
let [result] = blockUser(user, { params: { uuid: blockedUser._id } });
|
||||
const [result] = blockUser(user, { params: { uuid: blockedUser._id } });
|
||||
expect(user.inbox.blocks).to.eql([]);
|
||||
expect(result).to.eql([]);
|
||||
});
|
||||
|
||||
+12
-12
@@ -1,4 +1,5 @@
|
||||
/* eslint-disable camelcase */
|
||||
import { defaultsDeep } from 'lodash';
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../../helpers/common.helper';
|
||||
@@ -9,11 +10,10 @@ import {
|
||||
import i18n from '../../../../website/common/script/i18n';
|
||||
import content from '../../../../website/common/script/content/index';
|
||||
import errorMessage from '../../../../website/common/script/libs/errorMessage';
|
||||
import { defaultsDeep } from 'lodash';
|
||||
|
||||
describe('shared.ops.buy', () => {
|
||||
let user;
|
||||
let analytics = {track () {}};
|
||||
const analytics = { track () {} };
|
||||
|
||||
beforeEach(() => {
|
||||
user = generateUser({
|
||||
@@ -40,7 +40,7 @@ describe('shared.ops.buy', () => {
|
||||
analytics.track.restore();
|
||||
});
|
||||
|
||||
it('returns error when key is not provided', (done) => {
|
||||
it('returns error when key is not provided', done => {
|
||||
try {
|
||||
buy(user);
|
||||
} catch (err) {
|
||||
@@ -52,7 +52,7 @@ describe('shared.ops.buy', () => {
|
||||
|
||||
it('recovers 15 hp', () => {
|
||||
user.stats.hp = 30;
|
||||
buy(user, {params: {key: 'potion'}}, analytics);
|
||||
buy(user, { params: { key: 'potion' } }, analytics);
|
||||
expect(user.stats.hp).to.eql(45);
|
||||
|
||||
expect(analytics.track).to.be.calledOnce;
|
||||
@@ -61,7 +61,7 @@ describe('shared.ops.buy', () => {
|
||||
it('adds equipment to inventory', () => {
|
||||
user.stats.gp = 31;
|
||||
|
||||
buy(user, {params: {key: 'armor_warrior_1'}});
|
||||
buy(user, { params: { key: 'armor_warrior_1' } });
|
||||
|
||||
expect(user.items.gear.owned).to.eql({
|
||||
weapon_warrior_0: true,
|
||||
@@ -118,15 +118,15 @@ describe('shared.ops.buy', () => {
|
||||
type: 'quest',
|
||||
});
|
||||
|
||||
expect(user.items.quests).to.eql({dilatoryDistress1: 1});
|
||||
expect(user.items.quests).to.eql({ dilatoryDistress1: 1 });
|
||||
expect(user.stats.gp).to.equal(5);
|
||||
});
|
||||
|
||||
it('buys a special item', () => {
|
||||
user.stats.gp = 11;
|
||||
let item = content.special.thankyou;
|
||||
const item = content.special.thankyou;
|
||||
|
||||
let [data, message] = buy(user, {
|
||||
const [data, message] = buy(user, {
|
||||
params: {
|
||||
key: 'thankyou',
|
||||
},
|
||||
@@ -146,11 +146,11 @@ describe('shared.ops.buy', () => {
|
||||
|
||||
it('allows for bulk purchases', () => {
|
||||
user.stats.hp = 30;
|
||||
buy(user, {params: {key: 'potion'}, quantity: 2});
|
||||
buy(user, { params: { key: 'potion' }, quantity: 2 });
|
||||
expect(user.stats.hp).to.eql(50);
|
||||
});
|
||||
|
||||
it('errors if user supplies a non-numeric quantity', (done) => {
|
||||
it('errors if user supplies a non-numeric quantity', done => {
|
||||
try {
|
||||
buy(user, {
|
||||
params: {
|
||||
@@ -166,7 +166,7 @@ describe('shared.ops.buy', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('errors if user supplies a negative quantity', (done) => {
|
||||
it('errors if user supplies a negative quantity', done => {
|
||||
try {
|
||||
buy(user, {
|
||||
params: {
|
||||
@@ -182,7 +182,7 @@ describe('shared.ops.buy', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('errors if user supplies a decimal quantity', (done) => {
|
||||
it('errors if user supplies a decimal quantity', done => {
|
||||
try {
|
||||
buy(user, {
|
||||
params: {
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
generateUser,
|
||||
} from '../../../helpers/common.helper';
|
||||
import * as count from '../../../../website/common/script/count';
|
||||
import {BuyArmoireOperation} from '../../../../website/common/script/ops/buy/buyArmoire';
|
||||
import { BuyArmoireOperation } from '../../../../website/common/script/ops/buy/buyArmoire';
|
||||
import * as randomValFns from '../../../../website/common/script/libs/randomVal';
|
||||
import content from '../../../../website/common/script/content/index';
|
||||
import {
|
||||
@@ -13,11 +13,11 @@ import {
|
||||
import i18n from '../../../../website/common/script/i18n';
|
||||
|
||||
function getFullArmoire () {
|
||||
let fullArmoire = {};
|
||||
const fullArmoire = {};
|
||||
|
||||
_.each(content.gearTypes, (type) => {
|
||||
_.each(content.gear.tree[type].armoire, (gearObject) => {
|
||||
let armoireKey = gearObject.key;
|
||||
_.each(content.gearTypes, type => {
|
||||
_.each(content.gear.tree[type].armoire, gearObject => {
|
||||
const armoireKey = gearObject.key;
|
||||
|
||||
fullArmoire[armoireKey] = true;
|
||||
});
|
||||
@@ -28,10 +28,10 @@ function getFullArmoire () {
|
||||
|
||||
describe('shared.ops.buyArmoire', () => {
|
||||
let user;
|
||||
let YIELD_EQUIPMENT = 0.5;
|
||||
let YIELD_FOOD = 0.7;
|
||||
let YIELD_EXP = 0.9;
|
||||
let analytics = {track () {}};
|
||||
const YIELD_EQUIPMENT = 0.5;
|
||||
const YIELD_FOOD = 0.7;
|
||||
const YIELD_EXP = 0.9;
|
||||
const analytics = { track () {} };
|
||||
|
||||
function buyArmoire (_user, _req, _analytics) {
|
||||
const buyOp = new BuyArmoireOperation(_user, _req, _analytics);
|
||||
@@ -61,7 +61,7 @@ describe('shared.ops.buyArmoire', () => {
|
||||
});
|
||||
|
||||
context('failure conditions', () => {
|
||||
it('does not open if user does not have enough gold', (done) => {
|
||||
it('does not open if user does not have enough gold', done => {
|
||||
user.stats.gp = 50;
|
||||
|
||||
try {
|
||||
@@ -81,25 +81,25 @@ describe('shared.ops.buyArmoire', () => {
|
||||
|
||||
context('non-gear awards', () => {
|
||||
it('gives Experience', () => {
|
||||
let previousExp = user.stats.exp;
|
||||
const previousExp = user.stats.exp;
|
||||
randomValFns.trueRandom.returns(YIELD_EXP);
|
||||
|
||||
buyArmoire(user);
|
||||
|
||||
expect(user.items.gear.owned).to.eql({weapon_warrior_0: true});
|
||||
expect(user.items.gear.owned).to.eql({ weapon_warrior_0: true });
|
||||
expect(user.items.food).to.be.empty;
|
||||
expect(user.stats.exp).to.be.greaterThan(previousExp);
|
||||
expect(user.stats.gp).to.equal(100);
|
||||
});
|
||||
|
||||
it('gives food', () => {
|
||||
let previousExp = user.stats.exp;
|
||||
const previousExp = user.stats.exp;
|
||||
|
||||
randomValFns.trueRandom.returns(YIELD_FOOD);
|
||||
|
||||
buyArmoire(user);
|
||||
|
||||
expect(user.items.gear.owned).to.eql({weapon_warrior_0: true});
|
||||
expect(user.items.gear.owned).to.eql({ weapon_warrior_0: true });
|
||||
expect(user.items.food).to.not.be.empty;
|
||||
expect(user.stats.exp).to.equal(previousExp);
|
||||
expect(user.stats.gp).to.equal(100);
|
||||
@@ -113,7 +113,7 @@ describe('shared.ops.buyArmoire', () => {
|
||||
buyArmoire(user);
|
||||
|
||||
expect(user.items.gear.owned).to.eql(getFullArmoire());
|
||||
let armoireCount = count.remainingGearInSet(user.items.gear.owned, 'armoire');
|
||||
const armoireCount = count.remainingGearInSet(user.items.gear.owned, 'armoire');
|
||||
|
||||
expect(armoireCount).to.eql(0);
|
||||
|
||||
@@ -132,7 +132,7 @@ describe('shared.ops.buyArmoire', () => {
|
||||
|
||||
expect(_.size(user.items.gear.owned)).to.equal(2);
|
||||
|
||||
let armoireCount = count.remainingGearInSet(user.items.gear.owned, 'armoire');
|
||||
const armoireCount = count.remainingGearInSet(user.items.gear.owned, 'armoire');
|
||||
|
||||
expect(armoireCount).to.eql(_.size(getFullArmoire()) - 1);
|
||||
expect(user.items.food).to.be.empty;
|
||||
@@ -154,7 +154,7 @@ describe('shared.ops.buyArmoire', () => {
|
||||
|
||||
expect(_.size(user.items.gear.owned)).to.equal(3);
|
||||
|
||||
let armoireCount = count.remainingGearInSet(user.items.gear.owned, 'armoire');
|
||||
const armoireCount = count.remainingGearInSet(user.items.gear.owned, 'armoire');
|
||||
|
||||
expect(armoireCount).to.eql(_.size(getFullArmoire()) - 2);
|
||||
expect(user.stats.gp).to.eql(100);
|
||||
|
||||
@@ -8,21 +8,21 @@ import {
|
||||
BadRequest, NotAuthorized,
|
||||
} from '../../../../website/common/script/libs/errors';
|
||||
import i18n from '../../../../website/common/script/i18n';
|
||||
import {BuyGemOperation} from '../../../../website/common/script/ops/buy/buyGem';
|
||||
import { BuyGemOperation } from '../../../../website/common/script/ops/buy/buyGem';
|
||||
import planGemLimits from '../../../../website/common/script/libs/planGemLimits';
|
||||
|
||||
function buyGem (user, req, analytics) {
|
||||
let buyOp = new BuyGemOperation(user, req, analytics);
|
||||
const buyOp = new BuyGemOperation(user, req, analytics);
|
||||
|
||||
return buyOp.purchase();
|
||||
}
|
||||
|
||||
describe('shared.ops.buyGem', () => {
|
||||
let user;
|
||||
let analytics = {track () {}};
|
||||
let goldPoints = 40;
|
||||
let gemsBought = 40;
|
||||
let userGemAmount = 10;
|
||||
const analytics = { track () {} };
|
||||
const goldPoints = 40;
|
||||
const gemsBought = 40;
|
||||
const userGemAmount = 10;
|
||||
|
||||
beforeEach(() => {
|
||||
user = generateUser({
|
||||
@@ -45,9 +45,9 @@ describe('shared.ops.buyGem', () => {
|
||||
|
||||
context('Gems', () => {
|
||||
it('purchases gems', () => {
|
||||
let [, message] = buyGem(user, {params: {type: 'gems', key: 'gem'}}, analytics);
|
||||
const [, message] = buyGem(user, { params: { type: 'gems', key: 'gem' } }, analytics);
|
||||
|
||||
expect(message).to.equal(i18n.t('plusGem', {count: 1}));
|
||||
expect(message).to.equal(i18n.t('plusGem', { count: 1 }));
|
||||
expect(user.balance).to.equal(userGemAmount + 0.25);
|
||||
expect(user.purchased.plan.gemsBought).to.equal(1);
|
||||
expect(user.stats.gp).to.equal(goldPoints - planGemLimits.convRate);
|
||||
@@ -55,21 +55,21 @@ describe('shared.ops.buyGem', () => {
|
||||
});
|
||||
|
||||
it('purchases gems with a different language than the default', () => {
|
||||
let [, message] = buyGem(user, {params: {type: 'gems', key: 'gem'}, language: 'de'});
|
||||
const [, message] = buyGem(user, { params: { type: 'gems', key: 'gem' }, language: 'de' });
|
||||
|
||||
expect(message).to.equal(i18n.t('plusGem', {count: 1}, 'de'));
|
||||
expect(message).to.equal(i18n.t('plusGem', { count: 1 }, 'de'));
|
||||
expect(user.balance).to.equal(userGemAmount + 0.25);
|
||||
expect(user.purchased.plan.gemsBought).to.equal(1);
|
||||
expect(user.stats.gp).to.equal(goldPoints - planGemLimits.convRate);
|
||||
});
|
||||
|
||||
it('makes bulk purchases of gems', () => {
|
||||
let [, message] = buyGem(user, {
|
||||
params: {type: 'gems', key: 'gem'},
|
||||
const [, message] = buyGem(user, {
|
||||
params: { type: 'gems', key: 'gem' },
|
||||
quantity: 2,
|
||||
});
|
||||
|
||||
expect(message).to.equal(i18n.t('plusGem', {count: 2}));
|
||||
expect(message).to.equal(i18n.t('plusGem', { count: 2 }));
|
||||
expect(user.balance).to.equal(userGemAmount + 0.50);
|
||||
expect(user.purchased.plan.gemsBought).to.equal(2);
|
||||
expect(user.stats.gp).to.equal(goldPoints - planGemLimits.convRate * 2);
|
||||
@@ -77,9 +77,9 @@ describe('shared.ops.buyGem', () => {
|
||||
|
||||
|
||||
context('Failure conditions', () => {
|
||||
it('returns an error when key is not provided', (done) => {
|
||||
it('returns an error when key is not provided', done => {
|
||||
try {
|
||||
buyGem(user, {params: {type: 'gems'}});
|
||||
buyGem(user, { params: { type: 'gems' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(BadRequest);
|
||||
expect(err.message).to.equal(i18n.t('missingKeyParam'));
|
||||
@@ -87,11 +87,11 @@ describe('shared.ops.buyGem', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('prevents unsubscribed user from buying gems', (done) => {
|
||||
it('prevents unsubscribed user from buying gems', done => {
|
||||
delete user.purchased.plan.customerId;
|
||||
|
||||
try {
|
||||
buyGem(user, {params: {type: 'gems', key: 'gem'}});
|
||||
buyGem(user, { params: { type: 'gems', key: 'gem' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('mustSubscribeToPurchaseGems'));
|
||||
@@ -99,11 +99,11 @@ describe('shared.ops.buyGem', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('prevents user with not enough gold from buying gems', (done) => {
|
||||
it('prevents user with not enough gold from buying gems', done => {
|
||||
user.stats.gp = 15;
|
||||
|
||||
try {
|
||||
buyGem(user, {params: {type: 'gems', key: 'gem'}});
|
||||
buyGem(user, { params: { type: 'gems', key: 'gem' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('messageNotEnoughGold'));
|
||||
@@ -111,25 +111,25 @@ describe('shared.ops.buyGem', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('prevents user that have reached the conversion cap from buying gems', (done) => {
|
||||
it('prevents user that have reached the conversion cap from buying gems', done => {
|
||||
user.stats.gp = goldPoints;
|
||||
user.purchased.plan.gemsBought = gemsBought;
|
||||
|
||||
try {
|
||||
buyGem(user, {params: {type: 'gems', key: 'gem'}});
|
||||
buyGem(user, { params: { type: 'gems', key: 'gem' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('reachedGoldToGemCap', {convCap: planGemLimits.convCap}));
|
||||
expect(err.message).to.equal(i18n.t('reachedGoldToGemCap', { convCap: planGemLimits.convCap }));
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('prevents user from buying an invalid quantity', (done) => {
|
||||
it('prevents user from buying an invalid quantity', done => {
|
||||
user.stats.gp = goldPoints;
|
||||
user.purchased.plan.gemsBought = gemsBought;
|
||||
|
||||
try {
|
||||
buyGem(user, {params: {type: 'gems', key: 'gem'}, quantity: 'a'});
|
||||
buyGem(user, { params: { type: 'gems', key: 'gem' }, quantity: 'a' });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(BadRequest);
|
||||
expect(err.message).to.equal(i18n.t('invalidQuantity'));
|
||||
|
||||
@@ -10,7 +10,7 @@ import i18n from '../../../../website/common/script/i18n';
|
||||
|
||||
describe('shared.ops.buyHealthPotion', () => {
|
||||
let user;
|
||||
let analytics = {track () {}};
|
||||
const analytics = { track () {} };
|
||||
|
||||
function buyHealthPotion (_user, _req, _analytics) {
|
||||
const buyOp = new BuyHealthPotionOperation(_user, _req, _analytics);
|
||||
@@ -60,7 +60,7 @@ describe('shared.ops.buyHealthPotion', () => {
|
||||
expect(user.stats.gp).to.eql(175);
|
||||
});
|
||||
|
||||
it('does not purchase if not enough gp', (done) => {
|
||||
it('does not purchase if not enough gp', done => {
|
||||
user.stats.hp = 45;
|
||||
user.stats.gp = 5;
|
||||
try {
|
||||
@@ -75,7 +75,7 @@ describe('shared.ops.buyHealthPotion', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not purchase if hp is full', (done) => {
|
||||
it('does not purchase if hp is full', done => {
|
||||
user.stats.hp = 50;
|
||||
user.stats.gp = 40;
|
||||
try {
|
||||
@@ -90,7 +90,7 @@ describe('shared.ops.buyHealthPotion', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not allow potion purchases when hp is zero', (done) => {
|
||||
it('does not allow potion purchases when hp is zero', done => {
|
||||
user.stats.hp = 0;
|
||||
user.stats.gp = 40;
|
||||
try {
|
||||
@@ -105,7 +105,7 @@ describe('shared.ops.buyHealthPotion', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not allow potion purchases when hp is negative', (done) => {
|
||||
it('does not allow potion purchases when hp is negative', done => {
|
||||
user.stats.hp = -8;
|
||||
user.stats.gp = 40;
|
||||
try {
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
import sinon from 'sinon'; // eslint-disable-line no-shadow
|
||||
import { defaultsDeep } from 'lodash';
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../../helpers/common.helper';
|
||||
import {BuyMarketGearOperation} from '../../../../website/common/script/ops/buy/buyMarketGear';
|
||||
import { BuyMarketGearOperation } from '../../../../website/common/script/ops/buy/buyMarketGear';
|
||||
import shared from '../../../../website/common/script';
|
||||
import {
|
||||
BadRequest, NotAuthorized, NotFound,
|
||||
} from '../../../../website/common/script/libs/errors';
|
||||
import i18n from '../../../../website/common/script/i18n';
|
||||
import errorMessage from '../../../../website/common/script/libs/errorMessage';
|
||||
import { defaultsDeep } from 'lodash';
|
||||
|
||||
function buyGear (user, req, analytics) {
|
||||
let buyOp = new BuyMarketGearOperation(user, req, analytics);
|
||||
const buyOp = new BuyMarketGearOperation(user, req, analytics);
|
||||
|
||||
return buyOp.purchase();
|
||||
}
|
||||
|
||||
describe('shared.ops.buyMarketGear', () => {
|
||||
let user;
|
||||
let analytics = {track () {}};
|
||||
const analytics = { track () {} };
|
||||
|
||||
beforeEach(() => {
|
||||
user = generateUser({
|
||||
@@ -56,7 +56,7 @@ describe('shared.ops.buyMarketGear', () => {
|
||||
it('adds equipment to inventory', () => {
|
||||
user.stats.gp = 31;
|
||||
|
||||
buyGear(user, {params: {key: 'armor_warrior_1'}}, analytics);
|
||||
buyGear(user, { params: { key: 'armor_warrior_1' } }, analytics);
|
||||
|
||||
expect(user.items.gear.owned).to.eql({
|
||||
weapon_warrior_0: true,
|
||||
@@ -89,7 +89,7 @@ describe('shared.ops.buyMarketGear', () => {
|
||||
it('deducts gold from user', () => {
|
||||
user.stats.gp = 31;
|
||||
|
||||
buyGear(user, {params: {key: 'armor_warrior_1'}});
|
||||
buyGear(user, { params: { key: 'armor_warrior_1' } });
|
||||
|
||||
expect(user.stats.gp).to.eql(1);
|
||||
});
|
||||
@@ -98,7 +98,7 @@ describe('shared.ops.buyMarketGear', () => {
|
||||
user.stats.gp = 31;
|
||||
user.preferences.autoEquip = true;
|
||||
|
||||
buyGear(user, {params: {key: 'armor_warrior_1'}});
|
||||
buyGear(user, { params: { key: 'armor_warrior_1' } });
|
||||
|
||||
expect(user.items.gear.equipped).to.have.property('armor', 'armor_warrior_1');
|
||||
});
|
||||
@@ -106,7 +106,7 @@ describe('shared.ops.buyMarketGear', () => {
|
||||
it('updates the pinnedItems to the next item in the set if one exists', () => {
|
||||
user.stats.gp = 31;
|
||||
|
||||
buyGear(user, {params: {key: 'armor_warrior_1'}});
|
||||
buyGear(user, { params: { key: 'armor_warrior_1' } });
|
||||
|
||||
expect(user.pinnedItems).to.deep.include({
|
||||
type: 'marketGear',
|
||||
@@ -118,17 +118,17 @@ describe('shared.ops.buyMarketGear', () => {
|
||||
user.stats.gp = 31;
|
||||
user.preferences.autoEquip = false;
|
||||
|
||||
buyGear(user, {params: {key: 'armor_warrior_1'}});
|
||||
buyGear(user, { params: { key: 'armor_warrior_1' } });
|
||||
|
||||
expect(user.items.gear.equipped.property).to.not.equal('armor_warrior_1');
|
||||
});
|
||||
|
||||
it('does not buyGear equipment twice', (done) => {
|
||||
it('does not buyGear equipment twice', done => {
|
||||
user.stats.gp = 62;
|
||||
buyGear(user, {params: {key: 'armor_warrior_1'}});
|
||||
buyGear(user, { params: { key: 'armor_warrior_1' } });
|
||||
|
||||
try {
|
||||
buyGear(user, {params: {key: 'armor_warrior_1'}});
|
||||
buyGear(user, { params: { key: 'armor_warrior_1' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('equipmentAlreadyOwned'));
|
||||
@@ -136,12 +136,12 @@ describe('shared.ops.buyMarketGear', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not buy equipment of different class', (done) => {
|
||||
it('does not buy equipment of different class', done => {
|
||||
user.stats.gp = 82;
|
||||
user.stats.class = 'warrior';
|
||||
|
||||
try {
|
||||
buyGear(user, {params: {key: 'weapon_special_winter2018Rogue'}});
|
||||
buyGear(user, { params: { key: 'weapon_special_winter2018Rogue' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('cannotBuyItem'));
|
||||
@@ -149,11 +149,11 @@ describe('shared.ops.buyMarketGear', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not buy equipment in bulk', (done) => {
|
||||
it('does not buy equipment in bulk', done => {
|
||||
user.stats.gp = 82;
|
||||
|
||||
try {
|
||||
buyGear(user, {params: {key: 'armor_warrior_1'}, quantity: 3});
|
||||
buyGear(user, { params: { key: 'armor_warrior_1' }, quantity: 3 });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('messageNotAbleToBuyInBulk'));
|
||||
@@ -165,12 +165,12 @@ describe('shared.ops.buyMarketGear', () => {
|
||||
xit('removes one-handed weapon and shield if auto-equip is on and a two-hander is bought', () => {
|
||||
user.stats.gp = 100;
|
||||
user.preferences.autoEquip = true;
|
||||
buyGear(user, {params: {key: 'shield_warrior_1'}});
|
||||
user.ops.equip({params: {key: 'shield_warrior_1'}});
|
||||
buyGear(user, {params: {key: 'weapon_warrior_1'}});
|
||||
user.ops.equip({params: {key: 'weapon_warrior_1'}});
|
||||
buyGear(user, { params: { key: 'shield_warrior_1' } });
|
||||
user.ops.equip({ params: { key: 'shield_warrior_1' } });
|
||||
buyGear(user, { params: { key: 'weapon_warrior_1' } });
|
||||
user.ops.equip({ params: { key: 'weapon_warrior_1' } });
|
||||
|
||||
buyGear(user, {params: {key: 'weapon_wizard_1'}});
|
||||
buyGear(user, { params: { key: 'weapon_wizard_1' } });
|
||||
|
||||
expect(user.items.gear.equipped).to.have.property('shield', 'shield_base_0');
|
||||
expect(user.items.gear.equipped).to.have.property('weapon', 'weapon_wizard_1');
|
||||
@@ -180,22 +180,22 @@ describe('shared.ops.buyMarketGear', () => {
|
||||
xit('buyGears two-handed equipment but does not automatically remove sword or shield', () => {
|
||||
user.stats.gp = 100;
|
||||
user.preferences.autoEquip = false;
|
||||
buyGear(user, {params: {key: 'shield_warrior_1'}});
|
||||
user.ops.equip({params: {key: 'shield_warrior_1'}});
|
||||
buyGear(user, {params: {key: 'weapon_warrior_1'}});
|
||||
user.ops.equip({params: {key: 'weapon_warrior_1'}});
|
||||
buyGear(user, { params: { key: 'shield_warrior_1' } });
|
||||
user.ops.equip({ params: { key: 'shield_warrior_1' } });
|
||||
buyGear(user, { params: { key: 'weapon_warrior_1' } });
|
||||
user.ops.equip({ params: { key: 'weapon_warrior_1' } });
|
||||
|
||||
buyGear(user, {params: {key: 'weapon_wizard_1'}});
|
||||
buyGear(user, { params: { key: 'weapon_wizard_1' } });
|
||||
|
||||
expect(user.items.gear.equipped).to.have.property('shield', 'shield_warrior_1');
|
||||
expect(user.items.gear.equipped).to.have.property('weapon', 'weapon_warrior_1');
|
||||
});
|
||||
|
||||
it('does not buyGear equipment without enough Gold', (done) => {
|
||||
it('does not buyGear equipment without enough Gold', done => {
|
||||
user.stats.gp = 20;
|
||||
|
||||
try {
|
||||
buyGear(user, {params: {key: 'armor_warrior_1'}});
|
||||
buyGear(user, { params: { key: 'armor_warrior_1' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('messageNotEnoughGold'));
|
||||
@@ -204,7 +204,7 @@ describe('shared.ops.buyMarketGear', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('returns error when key is not provided', (done) => {
|
||||
it('returns error when key is not provided', done => {
|
||||
try {
|
||||
buyGear(user);
|
||||
} catch (err) {
|
||||
@@ -214,11 +214,11 @@ describe('shared.ops.buyMarketGear', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('returns error when item is not found', (done) => {
|
||||
let params = {key: 'armor_warrior_notExisting'};
|
||||
it('returns error when item is not found', done => {
|
||||
const params = { key: 'armor_warrior_notExisting' };
|
||||
|
||||
try {
|
||||
buyGear(user, {params});
|
||||
buyGear(user, { params });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotFound);
|
||||
expect(err.message).to.equal(errorMessage('itemNotFound', params));
|
||||
@@ -226,9 +226,9 @@ describe('shared.ops.buyMarketGear', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not buyGear equipment without the previous equipment', (done) => {
|
||||
it('does not buyGear equipment without the previous equipment', done => {
|
||||
try {
|
||||
buyGear(user, {params: {key: 'armor_warrior_2'}});
|
||||
buyGear(user, { params: { key: 'armor_warrior_2' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('previousGearNotOwned'));
|
||||
@@ -236,11 +236,11 @@ describe('shared.ops.buyMarketGear', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not buyGear equipment if user does not own prior item in sequence', (done) => {
|
||||
it('does not buyGear equipment if user does not own prior item in sequence', done => {
|
||||
user.stats.gp = 200;
|
||||
|
||||
try {
|
||||
buyGear(user, {params: {key: 'armor_warrior_2'}});
|
||||
buyGear(user, { params: { key: 'armor_warrior_2' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('previousGearNotOwned'));
|
||||
@@ -253,7 +253,7 @@ describe('shared.ops.buyMarketGear', () => {
|
||||
user.stats.gp = 200;
|
||||
user.items.gear.owned.head_special_2 = false;
|
||||
|
||||
buyGear(user, {params: {key: 'head_special_2'}});
|
||||
buyGear(user, { params: { key: 'head_special_2' } });
|
||||
|
||||
expect(user.items.gear.owned).to.have.property('head_special_2', true);
|
||||
});
|
||||
@@ -262,7 +262,7 @@ describe('shared.ops.buyMarketGear', () => {
|
||||
user.stats.gp = 200;
|
||||
user.items.gear.owned.shield_armoire_ramHornShield = false;
|
||||
|
||||
buyGear(user, {params: {key: 'shield_armoire_ramHornShield'}});
|
||||
buyGear(user, { params: { key: 'shield_armoire_ramHornShield' } });
|
||||
|
||||
expect(user.items.gear.owned).to.have.property('shield_armoire_ramHornShield', true);
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@ import errorMessage from '../../../../website/common/script/libs/errorMessage';
|
||||
|
||||
describe('shared.ops.buyMysterySet', () => {
|
||||
let user;
|
||||
let analytics = {track () {}};
|
||||
const analytics = { track () {} };
|
||||
|
||||
beforeEach(() => {
|
||||
user = generateUser({
|
||||
@@ -35,9 +35,9 @@ describe('shared.ops.buyMysterySet', () => {
|
||||
|
||||
context('Mystery Sets', () => {
|
||||
context('failure conditions', () => {
|
||||
it('does not grant mystery sets without Mystic Hourglasses', (done) => {
|
||||
it('does not grant mystery sets without Mystic Hourglasses', done => {
|
||||
try {
|
||||
buyMysterySet(user, {params: {key: '201501'}});
|
||||
buyMysterySet(user, { params: { key: '201501' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.eql(i18n.t('notEnoughHourglasses'));
|
||||
@@ -46,7 +46,7 @@ describe('shared.ops.buyMysterySet', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not grant mystery set that has already been purchased', (done) => {
|
||||
it('does not grant mystery set that has already been purchased', done => {
|
||||
user.purchased.plan.consecutive.trinkets = 1;
|
||||
user.items.gear.owned = {
|
||||
weapon_warrior_0: true,
|
||||
@@ -57,7 +57,7 @@ describe('shared.ops.buyMysterySet', () => {
|
||||
};
|
||||
|
||||
try {
|
||||
buyMysterySet(user, {params: {key: '301404'}});
|
||||
buyMysterySet(user, { params: { key: '301404' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotFound);
|
||||
expect(err.message).to.eql(i18n.t('mysterySetNotFound'));
|
||||
@@ -66,7 +66,7 @@ describe('shared.ops.buyMysterySet', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('returns error when key is not provided', (done) => {
|
||||
it('returns error when key is not provided', done => {
|
||||
try {
|
||||
buyMysterySet(user);
|
||||
} catch (err) {
|
||||
@@ -80,7 +80,7 @@ describe('shared.ops.buyMysterySet', () => {
|
||||
context('successful purchases', () => {
|
||||
it('buys Steampunk Accessories Set', () => {
|
||||
user.purchased.plan.consecutive.trinkets = 1;
|
||||
buyMysterySet(user, {params: {key: '301404'}}, analytics);
|
||||
buyMysterySet(user, { params: { key: '301404' } }, analytics);
|
||||
|
||||
expect(user.purchased.plan.consecutive.trinkets).to.eql(0);
|
||||
expect(user.items.gear.owned).to.have.property('weapon_warrior_0', true);
|
||||
|
||||
@@ -6,12 +6,12 @@ import i18n from '../../../../website/common/script/i18n';
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../../helpers/common.helper';
|
||||
import {BuyQuestWithGemOperation} from '../../../../website/common/script/ops/buy/buyQuestGem';
|
||||
import { BuyQuestWithGemOperation } from '../../../../website/common/script/ops/buy/buyQuestGem';
|
||||
|
||||
describe('shared.ops.buyQuestGems', () => {
|
||||
let user;
|
||||
let goldPoints = 40;
|
||||
let analytics = {track () {}};
|
||||
const goldPoints = 40;
|
||||
const analytics = { track () {} };
|
||||
|
||||
function buyQuest (_user, _req, _analytics) {
|
||||
const buyOp = new BuyQuestWithGemOperation(_user, _req, _analytics);
|
||||
@@ -20,7 +20,7 @@ describe('shared.ops.buyQuestGems', () => {
|
||||
}
|
||||
|
||||
before(() => {
|
||||
user = generateUser({'stats.class': 'rogue'});
|
||||
user = generateUser({ 'stats.class': 'rogue' });
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -34,29 +34,29 @@ describe('shared.ops.buyQuestGems', () => {
|
||||
});
|
||||
|
||||
context('successful purchase', () => {
|
||||
let userGemAmount = 10;
|
||||
const userGemAmount = 10;
|
||||
|
||||
before(() => {
|
||||
user.balance = userGemAmount;
|
||||
user.stats.gp = goldPoints;
|
||||
user.purchased.plan.gemsBought = 0;
|
||||
user.purchased.plan.customerId = 'customer-id';
|
||||
user.pinnedItems.push({type: 'quests', key: 'gryphon'});
|
||||
user.pinnedItems.push({ type: 'quests', key: 'gryphon' });
|
||||
});
|
||||
|
||||
it('purchases quests', () => {
|
||||
let key = 'gryphon';
|
||||
const key = 'gryphon';
|
||||
|
||||
buyQuest(user, {params: {key}});
|
||||
buyQuest(user, { params: { key } });
|
||||
|
||||
expect(user.items.quests[key]).to.equal(1);
|
||||
expect(pinnedGearUtils.removeItemByPath.notCalled).to.equal(true);
|
||||
});
|
||||
it('if a user\'s count of a quest scroll is negative, it will be reset to 0 before incrementing when they buy a new one.', () => {
|
||||
let key = 'dustbunnies';
|
||||
const key = 'dustbunnies';
|
||||
user.items.quests[key] = -1;
|
||||
|
||||
buyQuest(user, {params: {key}});
|
||||
buyQuest(user, { params: { key } });
|
||||
|
||||
expect(user.items.quests[key]).to.equal(1);
|
||||
expect(pinnedGearUtils.removeItemByPath.notCalled).to.equal(true);
|
||||
@@ -64,7 +64,7 @@ describe('shared.ops.buyQuestGems', () => {
|
||||
});
|
||||
|
||||
context('bulk purchase', () => {
|
||||
let userGemAmount = 10;
|
||||
const userGemAmount = 10;
|
||||
|
||||
beforeEach(() => {
|
||||
user.balance = userGemAmount;
|
||||
@@ -73,13 +73,13 @@ describe('shared.ops.buyQuestGems', () => {
|
||||
user.purchased.plan.customerId = 'customer-id';
|
||||
});
|
||||
|
||||
it('errors when user does not have enough gems', (done) => {
|
||||
it('errors when user does not have enough gems', done => {
|
||||
user.balance = 1;
|
||||
let key = 'gryphon';
|
||||
const key = 'gryphon';
|
||||
|
||||
try {
|
||||
buyQuest(user, {
|
||||
params: {key},
|
||||
params: { key },
|
||||
quantity: 2,
|
||||
});
|
||||
} catch (err) {
|
||||
@@ -90,10 +90,10 @@ describe('shared.ops.buyQuestGems', () => {
|
||||
});
|
||||
|
||||
it('makes bulk purchases of quests', () => {
|
||||
let key = 'gryphon';
|
||||
const key = 'gryphon';
|
||||
|
||||
buyQuest(user, {
|
||||
params: {key},
|
||||
params: { key },
|
||||
quantity: 3,
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../../helpers/common.helper';
|
||||
import {BuyQuestWithGoldOperation} from '../../../../website/common/script/ops/buy/buyQuestGold';
|
||||
import { BuyQuestWithGoldOperation } from '../../../../website/common/script/ops/buy/buyQuestGold';
|
||||
import {
|
||||
BadRequest,
|
||||
NotAuthorized,
|
||||
@@ -12,7 +12,7 @@ import errorMessage from '../../../../website/common/script/libs/errorMessage';
|
||||
|
||||
describe('shared.ops.buyQuest', () => {
|
||||
let user;
|
||||
let analytics = {track () {}};
|
||||
const analytics = { track () {} };
|
||||
|
||||
function buyQuest (_user, _req, _analytics) {
|
||||
const buyOp = new BuyQuestWithGoldOperation(_user, _req, _analytics);
|
||||
@@ -45,10 +45,10 @@ describe('shared.ops.buyQuest', () => {
|
||||
|
||||
it('if a user\'s count of a quest scroll is negative, it will be reset to 0 before incrementing when they buy a new one.', () => {
|
||||
user.stats.gp = 205;
|
||||
let key = 'dilatoryDistress1';
|
||||
const key = 'dilatoryDistress1';
|
||||
user.items.quests[key] = -1;
|
||||
buyQuest(user, {
|
||||
params: {key},
|
||||
params: { key },
|
||||
}, analytics);
|
||||
expect(user.items.quests[key]).to.equal(1);
|
||||
expect(user.stats.gp).to.equal(5);
|
||||
@@ -74,7 +74,7 @@ describe('shared.ops.buyQuest', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('does not buy a Quest scroll when an invalid quantity is passed', (done) => {
|
||||
it('does not buy a Quest scroll when an invalid quantity is passed', done => {
|
||||
user.stats.gp = 1000;
|
||||
try {
|
||||
buyQuest(user, {
|
||||
@@ -92,7 +92,7 @@ describe('shared.ops.buyQuest', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not buy Quests without enough Gold', (done) => {
|
||||
it('does not buy Quests without enough Gold', done => {
|
||||
user.stats.gp = 1;
|
||||
try {
|
||||
buyQuest(user, {
|
||||
@@ -109,7 +109,7 @@ describe('shared.ops.buyQuest', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not buy nonexistent Quests', (done) => {
|
||||
it('does not buy nonexistent Quests', done => {
|
||||
user.stats.gp = 9999;
|
||||
try {
|
||||
buyQuest(user, {
|
||||
@@ -119,14 +119,14 @@ describe('shared.ops.buyQuest', () => {
|
||||
});
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotFound);
|
||||
expect(err.message).to.equal(errorMessage('questNotFound', {key: 'snarfblatter'}));
|
||||
expect(err.message).to.equal(errorMessage('questNotFound', { key: 'snarfblatter' }));
|
||||
expect(user.items.quests).to.eql({});
|
||||
expect(user.stats.gp).to.equal(9999);
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('does not buy the Mystery of the Masterclassers', (done) => {
|
||||
it('does not buy the Mystery of the Masterclassers', done => {
|
||||
try {
|
||||
buyQuest(user, {
|
||||
params: {
|
||||
@@ -142,7 +142,7 @@ describe('shared.ops.buyQuest', () => {
|
||||
});
|
||||
|
||||
|
||||
it('does not buy Gem-premium Quests', (done) => {
|
||||
it('does not buy Gem-premium Quests', done => {
|
||||
user.stats.gp = 9999;
|
||||
try {
|
||||
buyQuest(user, {
|
||||
@@ -152,14 +152,14 @@ describe('shared.ops.buyQuest', () => {
|
||||
});
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('questNotGoldPurchasable', {key: 'kraken'}));
|
||||
expect(err.message).to.equal(i18n.t('questNotGoldPurchasable', { key: 'kraken' }));
|
||||
expect(user.items.quests).to.eql({});
|
||||
expect(user.stats.gp).to.equal(9999);
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('returns error when key is not provided', (done) => {
|
||||
it('returns error when key is not provided', done => {
|
||||
try {
|
||||
buyQuest(user);
|
||||
} catch (err) {
|
||||
@@ -169,7 +169,7 @@ describe('shared.ops.buyQuest', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not buy a quest without completing previous quests', (done) => {
|
||||
it('does not buy a quest without completing previous quests', done => {
|
||||
try {
|
||||
buyQuest(user, {
|
||||
params: {
|
||||
@@ -178,7 +178,7 @@ describe('shared.ops.buyQuest', () => {
|
||||
});
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('mustComplete', {quest: 'dilatoryDistress2'}));
|
||||
expect(err.message).to.equal(i18n.t('mustComplete', { quest: 'dilatoryDistress2' }));
|
||||
expect(user.items.quests).to.eql({});
|
||||
done();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {BuySpellOperation} from '../../../../website/common/script/ops/buy/buySpell';
|
||||
import { BuySpellOperation } from '../../../../website/common/script/ops/buy/buySpell';
|
||||
import {
|
||||
BadRequest,
|
||||
NotFound,
|
||||
@@ -13,7 +13,7 @@ import errorMessage from '../../../../website/common/script/libs/errorMessage';
|
||||
|
||||
describe('shared.ops.buySpecialSpell', () => {
|
||||
let user;
|
||||
let analytics = {track () {}};
|
||||
const analytics = { track () {} };
|
||||
|
||||
function buySpecialSpell (_user, _req, _analytics) {
|
||||
const buyOp = new BuySpellOperation(_user, _req, _analytics);
|
||||
@@ -29,7 +29,7 @@ describe('shared.ops.buySpecialSpell', () => {
|
||||
analytics.track.restore();
|
||||
});
|
||||
|
||||
it('throws an error if params.key is missing', (done) => {
|
||||
it('throws an error if params.key is missing', done => {
|
||||
try {
|
||||
buySpecialSpell(user);
|
||||
} catch (err) {
|
||||
@@ -39,7 +39,7 @@ describe('shared.ops.buySpecialSpell', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('throws an error if the spell doesn\'t exists', (done) => {
|
||||
it('throws an error if the spell doesn\'t exists', done => {
|
||||
try {
|
||||
buySpecialSpell(user, {
|
||||
params: {
|
||||
@@ -48,12 +48,12 @@ describe('shared.ops.buySpecialSpell', () => {
|
||||
});
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotFound);
|
||||
expect(err.message).to.equal(errorMessage('spellNotFound', {spellId: 'notExisting'}));
|
||||
expect(err.message).to.equal(errorMessage('spellNotFound', { spellId: 'notExisting' }));
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('throws an error if the user doesn\'t have enough gold', (done) => {
|
||||
it('throws an error if the user doesn\'t have enough gold', done => {
|
||||
user.stats.gp = 1;
|
||||
try {
|
||||
buySpecialSpell(user, {
|
||||
@@ -70,9 +70,9 @@ describe('shared.ops.buySpecialSpell', () => {
|
||||
|
||||
it('buys an item', () => {
|
||||
user.stats.gp = 11;
|
||||
let item = content.special.thankyou;
|
||||
const item = content.special.thankyou;
|
||||
|
||||
let [data, message] = buySpecialSpell(user, {
|
||||
const [data, message] = buySpecialSpell(user, {
|
||||
params: {
|
||||
key: 'thankyou',
|
||||
},
|
||||
|
||||
@@ -9,11 +9,11 @@ import {
|
||||
generateUser,
|
||||
} from '../../../helpers/common.helper';
|
||||
import errorMessage from '../../../../website/common/script/libs/errorMessage';
|
||||
import {BuyHourglassMountOperation} from '../../../../website/common/script/ops/buy/buyMount';
|
||||
import { BuyHourglassMountOperation } from '../../../../website/common/script/ops/buy/buyMount';
|
||||
|
||||
describe('common.ops.hourglassPurchase', () => {
|
||||
let user;
|
||||
let analytics = {track () {}};
|
||||
const analytics = { track () {} };
|
||||
|
||||
function buyMount (_user, _req, _analytics) {
|
||||
const buyOp = new BuyHourglassMountOperation(_user, _req, _analytics);
|
||||
@@ -31,9 +31,9 @@ describe('common.ops.hourglassPurchase', () => {
|
||||
});
|
||||
|
||||
context('failure conditions', () => {
|
||||
it('return error when key is not provided', (done) => {
|
||||
it('return error when key is not provided', done => {
|
||||
try {
|
||||
hourglassPurchase(user, {params: {}});
|
||||
hourglassPurchase(user, { params: {} });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(BadRequest);
|
||||
expect(err.message).to.eql(errorMessage('missingKeyParam'));
|
||||
@@ -41,9 +41,9 @@ describe('common.ops.hourglassPurchase', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('returns error when type is not provided', (done) => {
|
||||
it('returns error when type is not provided', done => {
|
||||
try {
|
||||
hourglassPurchase(user, {params: {key: 'Base'}});
|
||||
hourglassPurchase(user, { params: { key: 'Base' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(BadRequest);
|
||||
expect(err.message).to.eql(errorMessage('missingTypeParam'));
|
||||
@@ -51,19 +51,19 @@ describe('common.ops.hourglassPurchase', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('returns error when inccorect type is provided', (done) => {
|
||||
it('returns error when inccorect type is provided', done => {
|
||||
try {
|
||||
hourglassPurchase(user, {params: {type: 'notAType', key: 'MantisShrimp-Base'}});
|
||||
hourglassPurchase(user, { params: { type: 'notAType', key: 'MantisShrimp-Base' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.eql(i18n.t('typeNotAllowedHourglass', {allowedTypes: _.keys(content.timeTravelStable).toString()}));
|
||||
expect(err.message).to.eql(i18n.t('typeNotAllowedHourglass', { allowedTypes: _.keys(content.timeTravelStable).toString() }));
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('does not grant to pets without Mystic Hourglasses', (done) => {
|
||||
it('does not grant to pets without Mystic Hourglasses', done => {
|
||||
try {
|
||||
hourglassPurchase(user, {params: {type: 'pets', key: 'MantisShrimp-Base'}});
|
||||
hourglassPurchase(user, { params: { type: 'pets', key: 'MantisShrimp-Base' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.eql(i18n.t('notEnoughHourglasses'));
|
||||
@@ -71,9 +71,9 @@ describe('common.ops.hourglassPurchase', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not grant to mounts without Mystic Hourglasses', (done) => {
|
||||
it('does not grant to mounts without Mystic Hourglasses', done => {
|
||||
try {
|
||||
buyMount(user, {params: {key: 'MantisShrimp-Base'}});
|
||||
buyMount(user, { params: { key: 'MantisShrimp-Base' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.eql(i18n.t('notEnoughHourglasses'));
|
||||
@@ -81,11 +81,11 @@ describe('common.ops.hourglassPurchase', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not grant pet that is not part of the Time Travel Stable', (done) => {
|
||||
it('does not grant pet that is not part of the Time Travel Stable', done => {
|
||||
user.purchased.plan.consecutive.trinkets = 1;
|
||||
|
||||
try {
|
||||
hourglassPurchase(user, {params: {type: 'pets', key: 'Wolf-Veteran'}});
|
||||
hourglassPurchase(user, { params: { type: 'pets', key: 'Wolf-Veteran' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.eql(i18n.t('notAllowedHourglass'));
|
||||
@@ -93,11 +93,11 @@ describe('common.ops.hourglassPurchase', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not grant mount that is not part of the Time Travel Stable', (done) => {
|
||||
it('does not grant mount that is not part of the Time Travel Stable', done => {
|
||||
user.purchased.plan.consecutive.trinkets = 1;
|
||||
|
||||
try {
|
||||
buyMount(user, {params: {key: 'Orca-Base'}});
|
||||
buyMount(user, { params: { key: 'Orca-Base' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.eql(i18n.t('notAllowedHourglass'));
|
||||
@@ -105,14 +105,14 @@ describe('common.ops.hourglassPurchase', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not grant pet that has already been purchased', (done) => {
|
||||
it('does not grant pet that has already been purchased', done => {
|
||||
user.purchased.plan.consecutive.trinkets = 1;
|
||||
user.items.pets = {
|
||||
'MantisShrimp-Base': true,
|
||||
};
|
||||
|
||||
try {
|
||||
hourglassPurchase(user, {params: {type: 'pets', key: 'MantisShrimp-Base'}});
|
||||
hourglassPurchase(user, { params: { type: 'pets', key: 'MantisShrimp-Base' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.eql(i18n.t('petsAlreadyOwned'));
|
||||
@@ -120,14 +120,14 @@ describe('common.ops.hourglassPurchase', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not grant mount that has already been purchased', (done) => {
|
||||
it('does not grant mount that has already been purchased', done => {
|
||||
user.purchased.plan.consecutive.trinkets = 1;
|
||||
user.items.mounts = {
|
||||
'MantisShrimp-Base': true,
|
||||
};
|
||||
|
||||
try {
|
||||
buyMount(user, {params: {key: 'MantisShrimp-Base'}});
|
||||
buyMount(user, { params: { key: 'MantisShrimp-Base' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.eql(i18n.t('mountsAlreadyOwned'));
|
||||
@@ -140,21 +140,21 @@ describe('common.ops.hourglassPurchase', () => {
|
||||
it('buys a pet', () => {
|
||||
user.purchased.plan.consecutive.trinkets = 2;
|
||||
|
||||
let [, message] = hourglassPurchase(user, {params: {type: 'pets', key: 'MantisShrimp-Base'}}, analytics);
|
||||
const [, message] = hourglassPurchase(user, { params: { type: 'pets', key: 'MantisShrimp-Base' } }, analytics);
|
||||
|
||||
expect(message).to.eql(i18n.t('hourglassPurchase'));
|
||||
expect(user.purchased.plan.consecutive.trinkets).to.eql(1);
|
||||
expect(user.items.pets).to.eql({'MantisShrimp-Base': 5});
|
||||
expect(user.items.pets).to.eql({ 'MantisShrimp-Base': 5 });
|
||||
expect(analytics.track).to.be.calledOnce;
|
||||
});
|
||||
|
||||
it('buys a mount', () => {
|
||||
user.purchased.plan.consecutive.trinkets = 2;
|
||||
|
||||
let [, message] = buyMount(user, {params: {key: 'MantisShrimp-Base'}});
|
||||
const [, message] = buyMount(user, { params: { key: 'MantisShrimp-Base' } });
|
||||
expect(message).to.eql(i18n.t('hourglassPurchase'));
|
||||
expect(user.purchased.plan.consecutive.trinkets).to.eql(1);
|
||||
expect(user.items.mounts).to.eql({'MantisShrimp-Base': true});
|
||||
expect(user.items.mounts).to.eql({ 'MantisShrimp-Base': true });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import forEach from 'lodash/forEach';
|
||||
import moment from 'moment';
|
||||
import purchase from '../../../../website/common/script/ops/buy/purchase';
|
||||
import * as pinnedGearUtils from '../../../../website/common/script/ops/pinnedGearUtils';
|
||||
import {
|
||||
@@ -9,17 +11,15 @@ import i18n from '../../../../website/common/script/i18n';
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../../helpers/common.helper';
|
||||
import forEach from 'lodash/forEach';
|
||||
import moment from 'moment';
|
||||
|
||||
describe('shared.ops.purchase', () => {
|
||||
const SEASONAL_FOOD = 'Meat';
|
||||
let user;
|
||||
let goldPoints = 40;
|
||||
let analytics = {track () {}};
|
||||
const goldPoints = 40;
|
||||
const analytics = { track () {} };
|
||||
|
||||
before(() => {
|
||||
user = generateUser({'stats.class': 'rogue'});
|
||||
user = generateUser({ 'stats.class': 'rogue' });
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -33,9 +33,9 @@ describe('shared.ops.purchase', () => {
|
||||
});
|
||||
|
||||
context('failure conditions', () => {
|
||||
it('returns an error when type is not provided', (done) => {
|
||||
it('returns an error when type is not provided', done => {
|
||||
try {
|
||||
purchase(user, {params: {}});
|
||||
purchase(user, { params: {} });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(BadRequest);
|
||||
expect(err.message).to.equal(i18n.t('typeRequired'));
|
||||
@@ -44,9 +44,9 @@ describe('shared.ops.purchase', () => {
|
||||
});
|
||||
|
||||
|
||||
it('returns error when unknown type is provided', (done) => {
|
||||
it('returns error when unknown type is provided', done => {
|
||||
try {
|
||||
purchase(user, {params: {type: 'randomType', key: 'gem'}});
|
||||
purchase(user, { params: { type: 'randomType', key: 'gem' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotFound);
|
||||
expect(err.message).to.equal(i18n.t('notAccteptedType'));
|
||||
@@ -54,11 +54,11 @@ describe('shared.ops.purchase', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('returns error when user attempts to purchase a piece of gear they own', (done) => {
|
||||
it('returns error when user attempts to purchase a piece of gear they own', done => {
|
||||
user.items.gear.owned['shield_rogue_1'] = true; // eslint-disable-line dot-notation
|
||||
|
||||
try {
|
||||
purchase(user, {params: {type: 'gear', key: 'shield_rogue_1'}});
|
||||
purchase(user, { params: { type: 'gear', key: 'shield_rogue_1' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('alreadyHave'));
|
||||
@@ -66,19 +66,19 @@ describe('shared.ops.purchase', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('returns error when unknown item is requested', (done) => {
|
||||
it('returns error when unknown item is requested', done => {
|
||||
try {
|
||||
purchase(user, {params: {type: 'gear', key: 'randomKey'}});
|
||||
purchase(user, { params: { type: 'gear', key: 'randomKey' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotFound);
|
||||
expect(err.message).to.equal(i18n.t('contentKeyNotFound', {type: 'gear'}));
|
||||
expect(err.message).to.equal(i18n.t('contentKeyNotFound', { type: 'gear' }));
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('returns error when user does not have permission to buy an item', (done) => {
|
||||
it('returns error when user does not have permission to buy an item', done => {
|
||||
try {
|
||||
purchase(user, {params: {type: 'gear', key: 'eyewear_mystery_301405'}});
|
||||
purchase(user, { params: { type: 'gear', key: 'eyewear_mystery_301405' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('messageNotAvailable'));
|
||||
@@ -86,9 +86,9 @@ describe('shared.ops.purchase', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('returns error when user does not have enough gems to buy an item', (done) => {
|
||||
it('returns error when user does not have enough gems to buy an item', done => {
|
||||
try {
|
||||
purchase(user, {params: {type: 'gear', key: 'headAccessory_special_wolfEars'}});
|
||||
purchase(user, { params: { type: 'gear', key: 'headAccessory_special_wolfEars' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('notEnoughGems'));
|
||||
@@ -97,11 +97,11 @@ describe('shared.ops.purchase', () => {
|
||||
});
|
||||
|
||||
|
||||
it('returns error when item is not found', (done) => {
|
||||
let params = {key: 'notExisting', type: 'food'};
|
||||
it('returns error when item is not found', done => {
|
||||
const params = { key: 'notExisting', type: 'food' };
|
||||
|
||||
try {
|
||||
purchase(user, {params});
|
||||
purchase(user, { params });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotFound);
|
||||
expect(err.message).to.equal(i18n.t('contentKeyNotFound', params));
|
||||
@@ -109,12 +109,12 @@ describe('shared.ops.purchase', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('returns error when user supplies a non-numeric quantity', (done) => {
|
||||
let type = 'eggs';
|
||||
let key = 'Wolf';
|
||||
it('returns error when user supplies a non-numeric quantity', done => {
|
||||
const type = 'eggs';
|
||||
const key = 'Wolf';
|
||||
|
||||
try {
|
||||
purchase(user, {params: {type, key}, quantity: 'jamboree'}, analytics);
|
||||
purchase(user, { params: { type, key }, quantity: 'jamboree' }, analytics);
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(BadRequest);
|
||||
expect(err.message).to.equal(i18n.t('invalidQuantity'));
|
||||
@@ -122,13 +122,13 @@ describe('shared.ops.purchase', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('returns error when user supplies a negative quantity', (done) => {
|
||||
let type = 'eggs';
|
||||
let key = 'Wolf';
|
||||
it('returns error when user supplies a negative quantity', done => {
|
||||
const type = 'eggs';
|
||||
const key = 'Wolf';
|
||||
user.balance = 10;
|
||||
|
||||
try {
|
||||
purchase(user, {params: {type, key}, quantity: -2}, analytics);
|
||||
purchase(user, { params: { type, key }, quantity: -2 }, analytics);
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(BadRequest);
|
||||
expect(err.message).to.equal(i18n.t('invalidQuantity'));
|
||||
@@ -136,13 +136,13 @@ describe('shared.ops.purchase', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('returns error when user supplies a decimal quantity', (done) => {
|
||||
let type = 'eggs';
|
||||
let key = 'Wolf';
|
||||
it('returns error when user supplies a decimal quantity', done => {
|
||||
const type = 'eggs';
|
||||
const key = 'Wolf';
|
||||
user.balance = 10;
|
||||
|
||||
try {
|
||||
purchase(user, {params: {type, key}, quantity: 2.9}, analytics);
|
||||
purchase(user, { params: { type, key }, quantity: 2.9 }, analytics);
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(BadRequest);
|
||||
expect(err.message).to.equal(i18n.t('invalidQuantity'));
|
||||
@@ -152,25 +152,25 @@ describe('shared.ops.purchase', () => {
|
||||
});
|
||||
|
||||
context('successful purchase', () => {
|
||||
let userGemAmount = 10;
|
||||
const userGemAmount = 10;
|
||||
|
||||
before(() => {
|
||||
user.balance = userGemAmount;
|
||||
user.stats.gp = goldPoints;
|
||||
user.purchased.plan.gemsBought = 0;
|
||||
user.purchased.plan.customerId = 'customer-id';
|
||||
user.pinnedItems.push({type: 'eggs', key: 'Wolf'});
|
||||
user.pinnedItems.push({type: 'hatchingPotions', key: 'Base'});
|
||||
user.pinnedItems.push({type: 'food', key: SEASONAL_FOOD});
|
||||
user.pinnedItems.push({type: 'gear', key: 'headAccessory_special_tigerEars'});
|
||||
user.pinnedItems.push({type: 'bundles', key: 'featheredFriends'});
|
||||
user.pinnedItems.push({ type: 'eggs', key: 'Wolf' });
|
||||
user.pinnedItems.push({ type: 'hatchingPotions', key: 'Base' });
|
||||
user.pinnedItems.push({ type: 'food', key: SEASONAL_FOOD });
|
||||
user.pinnedItems.push({ type: 'gear', key: 'headAccessory_special_tigerEars' });
|
||||
user.pinnedItems.push({ type: 'bundles', key: 'featheredFriends' });
|
||||
});
|
||||
|
||||
it('purchases eggs', () => {
|
||||
let type = 'eggs';
|
||||
let key = 'Wolf';
|
||||
const type = 'eggs';
|
||||
const key = 'Wolf';
|
||||
|
||||
purchase(user, {params: {type, key}}, analytics);
|
||||
purchase(user, { params: { type, key } }, analytics);
|
||||
|
||||
expect(user.items[type][key]).to.equal(1);
|
||||
expect(pinnedGearUtils.removeItemByPath.notCalled).to.equal(true);
|
||||
@@ -178,50 +178,50 @@ describe('shared.ops.purchase', () => {
|
||||
});
|
||||
|
||||
it('purchases hatchingPotions', () => {
|
||||
let type = 'hatchingPotions';
|
||||
let key = 'Base';
|
||||
const type = 'hatchingPotions';
|
||||
const key = 'Base';
|
||||
|
||||
purchase(user, {params: {type, key}});
|
||||
purchase(user, { params: { type, key } });
|
||||
|
||||
expect(user.items[type][key]).to.equal(1);
|
||||
expect(pinnedGearUtils.removeItemByPath.notCalled).to.equal(true);
|
||||
});
|
||||
|
||||
it('purchases food', () => {
|
||||
let type = 'food';
|
||||
let key = SEASONAL_FOOD;
|
||||
const type = 'food';
|
||||
const key = SEASONAL_FOOD;
|
||||
|
||||
purchase(user, {params: {type, key}});
|
||||
purchase(user, { params: { type, key } });
|
||||
|
||||
expect(user.items[type][key]).to.equal(1);
|
||||
expect(pinnedGearUtils.removeItemByPath.notCalled).to.equal(true);
|
||||
});
|
||||
|
||||
it('purchases gear', () => {
|
||||
let type = 'gear';
|
||||
let key = 'headAccessory_special_tigerEars';
|
||||
const type = 'gear';
|
||||
const key = 'headAccessory_special_tigerEars';
|
||||
|
||||
purchase(user, {params: {type, key}});
|
||||
purchase(user, { params: { type, key } });
|
||||
|
||||
expect(user.items.gear.owned[key]).to.be.true;
|
||||
expect(pinnedGearUtils.removeItemByPath.calledOnce).to.equal(true);
|
||||
});
|
||||
|
||||
it('purchases quest bundles', () => {
|
||||
let startingBalance = user.balance;
|
||||
let clock = sandbox.useFakeTimers(moment('2019-05-20').valueOf());
|
||||
let type = 'bundles';
|
||||
let key = 'featheredFriends';
|
||||
let price = 1.75;
|
||||
let questList = [
|
||||
const startingBalance = user.balance;
|
||||
const clock = sandbox.useFakeTimers(moment('2019-05-20').valueOf());
|
||||
const type = 'bundles';
|
||||
const key = 'featheredFriends';
|
||||
const price = 1.75;
|
||||
const questList = [
|
||||
'falcon',
|
||||
'harpy',
|
||||
'owl',
|
||||
];
|
||||
|
||||
purchase(user, {params: {type, key}});
|
||||
purchase(user, { params: { type, key } });
|
||||
|
||||
forEach(questList, (bundledKey) => {
|
||||
forEach(questList, bundledKey => {
|
||||
expect(user.items.quests[bundledKey]).to.equal(1);
|
||||
});
|
||||
|
||||
@@ -233,7 +233,7 @@ describe('shared.ops.purchase', () => {
|
||||
});
|
||||
|
||||
context('bulk purchase', () => {
|
||||
let userGemAmount = 10;
|
||||
const userGemAmount = 10;
|
||||
|
||||
beforeEach(() => {
|
||||
user.balance = userGemAmount;
|
||||
@@ -242,14 +242,14 @@ describe('shared.ops.purchase', () => {
|
||||
user.purchased.plan.customerId = 'customer-id';
|
||||
});
|
||||
|
||||
it('errors when user does not have enough gems', (done) => {
|
||||
it('errors when user does not have enough gems', done => {
|
||||
user.balance = 1;
|
||||
let type = 'eggs';
|
||||
let key = 'TigerCub';
|
||||
const type = 'eggs';
|
||||
const key = 'TigerCub';
|
||||
|
||||
try {
|
||||
purchase(user, {
|
||||
params: {type, key},
|
||||
params: { type, key },
|
||||
quantity: 2,
|
||||
});
|
||||
} catch (err) {
|
||||
@@ -260,11 +260,11 @@ describe('shared.ops.purchase', () => {
|
||||
});
|
||||
|
||||
it('makes bulk purchases of eggs', () => {
|
||||
let type = 'eggs';
|
||||
let key = 'TigerCub';
|
||||
const type = 'eggs';
|
||||
const key = 'TigerCub';
|
||||
|
||||
purchase(user, {
|
||||
params: {type, key},
|
||||
params: { type, key },
|
||||
quantity: 2,
|
||||
});
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ describe('shared.ops.changeClass', () => {
|
||||
user.stats.flagSelected = false;
|
||||
});
|
||||
|
||||
it('user is not level 10', (done) => {
|
||||
it('user is not level 10', done => {
|
||||
user.stats.lvl = 9;
|
||||
try {
|
||||
changeClass(user, {query: {class: 'rogue'}});
|
||||
changeClass(user, { query: { class: 'rogue' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('lvl10ChangeClass'));
|
||||
@@ -30,12 +30,12 @@ describe('shared.ops.changeClass', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('req.query.class is an invalid class', (done) => {
|
||||
it('req.query.class is an invalid class', done => {
|
||||
user.flags.classSelected = false;
|
||||
user.preferences.disableClasses = false;
|
||||
|
||||
try {
|
||||
changeClass(user, {query: {class: 'cellist'}});
|
||||
changeClass(user, { query: { class: 'cellist' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(BadRequest);
|
||||
expect(err.message).to.equal(i18n.t('invalidClass'));
|
||||
@@ -44,13 +44,13 @@ describe('shared.ops.changeClass', () => {
|
||||
});
|
||||
|
||||
context('req.query.class is a valid class', () => {
|
||||
it('errors if user.stats.flagSelected is true and user.balance < 0.75', (done) => {
|
||||
it('errors if user.stats.flagSelected is true and user.balance < 0.75', done => {
|
||||
user.flags.classSelected = true;
|
||||
user.preferences.disableClasses = false;
|
||||
user.balance = 0;
|
||||
|
||||
try {
|
||||
changeClass(user, {query: {class: 'rogue'}});
|
||||
changeClass(user, { query: { class: 'rogue' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('notEnoughGems'));
|
||||
@@ -63,7 +63,7 @@ describe('shared.ops.changeClass', () => {
|
||||
user.items.gear.owned.weapon_healer_3 = true;
|
||||
user.items.gear.equipped.weapon = 'weapon_healer_3';
|
||||
|
||||
let [data] = changeClass(user, {query: {class: 'rogue'}});
|
||||
const [data] = changeClass(user, { query: { class: 'rogue' } });
|
||||
expect(data).to.eql({
|
||||
preferences: user.preferences,
|
||||
stats: user.stats,
|
||||
@@ -92,7 +92,7 @@ describe('shared.ops.changeClass', () => {
|
||||
user.stats.int = 4;
|
||||
user.flags.classSelected = true;
|
||||
|
||||
let [data] = changeClass(user);
|
||||
const [data] = changeClass(user);
|
||||
expect(data).to.eql({
|
||||
preferences: user.preferences,
|
||||
stats: user.stats,
|
||||
@@ -112,7 +112,7 @@ describe('shared.ops.changeClass', () => {
|
||||
});
|
||||
|
||||
context('has user.preferences.disableClasses !== true', () => {
|
||||
it('and less than 3 gems', (done) => {
|
||||
it('and less than 3 gems', done => {
|
||||
user.balance = 0.5;
|
||||
try {
|
||||
changeClass(user);
|
||||
@@ -132,7 +132,7 @@ describe('shared.ops.changeClass', () => {
|
||||
user.stats.int = 4;
|
||||
user.flags.classSelected = true;
|
||||
|
||||
let [data] = changeClass(user);
|
||||
const [data] = changeClass(user);
|
||||
expect(data).to.eql({
|
||||
preferences: user.preferences,
|
||||
stats: user.stats,
|
||||
|
||||
@@ -18,7 +18,7 @@ describe('shared.ops.disableClasses', () => {
|
||||
user.preferences.autoAllocate = false;
|
||||
user.stats.points = 2;
|
||||
|
||||
let [data] = disableClasses(user);
|
||||
const [data] = disableClasses(user);
|
||||
expect(data).to.eql({
|
||||
preferences: user.preferences,
|
||||
stats: user.stats,
|
||||
|
||||
+19
-19
@@ -28,58 +28,58 @@ describe('shared.ops.equip', () => {
|
||||
},
|
||||
},
|
||||
},
|
||||
stats: {gp: 200},
|
||||
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'}});
|
||||
equip(user, { params: { key: 'weapon_warrior_1' } });
|
||||
|
||||
// one-handed to one-handed
|
||||
let [, message] = equip(user, {params: {key: 'weapon_warrior_2'}});
|
||||
let [, message] = equip(user, { params: { key: 'weapon_warrior_2' } });
|
||||
expect(message).to.not.exist;
|
||||
|
||||
// one-handed to two-handed
|
||||
[, message] = equip(user, {params: {key: 'weapon_wizard_1'}});
|
||||
[, message] = equip(user, { params: { key: 'weapon_wizard_1' } });
|
||||
expect(message).to.not.exist;
|
||||
|
||||
// two-handed to two-handed
|
||||
[, message] = equip(user, {params: {key: 'weapon_wizard_2'}});
|
||||
[, message] = equip(user, { params: { key: 'weapon_wizard_2' } });
|
||||
expect(message).to.not.exist;
|
||||
|
||||
// two-handed to one-handed
|
||||
[, message] = equip(user, {params: {key: 'weapon_warrior_2'}});
|
||||
[, message] = equip(user, { params: { key: 'weapon_warrior_2' } });
|
||||
expect(message).to.not.exist;
|
||||
});
|
||||
|
||||
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'}});
|
||||
equip(user, { params: { key: 'weapon_warrior_1' } });
|
||||
equip(user, { params: { key: 'shield_warrior_1' } });
|
||||
|
||||
// equipping two-hander
|
||||
let [data, message] = equip(user, {params: {key: 'weapon_wizard_1'}});
|
||||
let weapon = content.gear.flat.weapon_wizard_1;
|
||||
let item = content.gear.flat.shield_warrior_1;
|
||||
const [data, message] = equip(user, { params: { key: 'weapon_wizard_1' } });
|
||||
const weapon = content.gear.flat.weapon_wizard_1;
|
||||
const item = content.gear.flat.shield_warrior_1;
|
||||
|
||||
let res = {data, message};
|
||||
const res = { data, message };
|
||||
expect(res).to.eql({
|
||||
message: i18n.t('messageTwoHandedEquip', {twoHandedText: weapon.text(), offHandedText: item.text()}),
|
||||
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;
|
||||
equip(user, { params: { key: 'weapon_wizard_1' } });
|
||||
const weapon = content.gear.flat.weapon_wizard_1;
|
||||
const shield = content.gear.flat.shield_warrior_1;
|
||||
|
||||
let [data, message] = equip(user, {params: {key: 'shield_warrior_1'}});
|
||||
const [data, message] = equip(user, { params: { key: 'shield_warrior_1' } });
|
||||
|
||||
let res = {data, message};
|
||||
const res = { data, message };
|
||||
expect(res).to.eql({
|
||||
message: i18n.t('messageTwoHandedUnequip', {twoHandedText: weapon.text(), offHandedText: shield.text()}),
|
||||
message: i18n.t('messageTwoHandedUnequip', { twoHandedText: weapon.text(), offHandedText: shield.text() }),
|
||||
data: user.items,
|
||||
});
|
||||
});
|
||||
|
||||
+28
-28
@@ -19,7 +19,7 @@ describe('shared.ops.feed', () => {
|
||||
});
|
||||
|
||||
context('failure conditions', () => {
|
||||
it('does not allow feeding without specifying pet and food', (done) => {
|
||||
it('does not allow feeding without specifying pet and food', done => {
|
||||
try {
|
||||
feed(user);
|
||||
} catch (err) {
|
||||
@@ -29,9 +29,9 @@ describe('shared.ops.feed', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not allow feeding if pet name format is invalid', (done) => {
|
||||
it('does not allow feeding if pet name format is invalid', done => {
|
||||
try {
|
||||
feed(user, {params: {pet: 'invalid', food: 'food'}});
|
||||
feed(user, { params: { pet: 'invalid', food: 'food' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(BadRequest);
|
||||
expect(err.message).to.equal(errorMessage('invalidPetName'));
|
||||
@@ -39,9 +39,9 @@ describe('shared.ops.feed', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not allow feeding if food does not exist', (done) => {
|
||||
it('does not allow feeding if food does not exist', done => {
|
||||
try {
|
||||
feed(user, {params: {pet: 'Wolf-Red', food: 'invalid food name'}});
|
||||
feed(user, { params: { pet: 'Wolf-Red', food: 'invalid food name' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotFound);
|
||||
expect(err.message).to.equal(errorMessage('invalidFoodName'));
|
||||
@@ -49,9 +49,9 @@ describe('shared.ops.feed', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not allow feeding if pet is not owned', (done) => {
|
||||
it('does not allow feeding if pet is not owned', done => {
|
||||
try {
|
||||
feed(user, {params: {pet: 'Wolf-Red', food: 'Meat'}});
|
||||
feed(user, { params: { pet: 'Wolf-Red', food: 'Meat' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotFound);
|
||||
expect(err.message).to.equal(i18n.t('messagePetNotFound'));
|
||||
@@ -59,10 +59,10 @@ describe('shared.ops.feed', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not allow feeding if food is not owned', (done) => {
|
||||
it('does not allow feeding if food is not owned', done => {
|
||||
user.items.pets['Wolf-Base'] = 5;
|
||||
try {
|
||||
feed(user, {params: {pet: 'Wolf-Base', food: 'Meat'}});
|
||||
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'));
|
||||
@@ -70,11 +70,11 @@ describe('shared.ops.feed', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not allow feeding of special pets', (done) => {
|
||||
it('does not allow feeding of special pets', done => {
|
||||
user.items.pets['Wolf-Veteran'] = 5;
|
||||
user.items.food.Meat = 1;
|
||||
try {
|
||||
feed(user, {params: {pet: 'Wolf-Veteran', food: 'Meat'}});
|
||||
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'));
|
||||
@@ -82,12 +82,12 @@ describe('shared.ops.feed', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not allow feeding of mounts', (done) => {
|
||||
it('does not allow feeding of mounts', done => {
|
||||
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'}});
|
||||
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'));
|
||||
@@ -101,9 +101,9 @@ describe('shared.ops.feed', () => {
|
||||
user.items.pets['Wolf-Base'] = 5;
|
||||
user.items.food.Saddle = 2;
|
||||
user.items.currentPet = 'Wolf-Base';
|
||||
let pet = content.petInfo['Wolf-Base'];
|
||||
const pet = content.petInfo['Wolf-Base'];
|
||||
|
||||
let [data, message] = feed(user, {params: {pet: 'Wolf-Base', food: 'Saddle'}});
|
||||
const [data, message] = feed(user, { params: { pet: 'Wolf-Base', food: 'Saddle' } });
|
||||
expect(data).to.eql(user.items.pets['Wolf-Base']);
|
||||
expect(message).to.eql(i18n.t('messageEvolve', {
|
||||
egg: pet.text(),
|
||||
@@ -119,10 +119,10 @@ describe('shared.ops.feed', () => {
|
||||
user.items.pets['Wolf-Base'] = 5;
|
||||
user.items.food.Meat = 2;
|
||||
|
||||
let food = content.food.Meat;
|
||||
let pet = content.petInfo['Wolf-Base'];
|
||||
const food = content.food.Meat;
|
||||
const pet = content.petInfo['Wolf-Base'];
|
||||
|
||||
let [data, message] = feed(user, {params: {pet: 'Wolf-Base', food: 'Meat'}});
|
||||
const [data, message] = feed(user, { params: { pet: 'Wolf-Base', food: 'Meat' } });
|
||||
expect(data).to.eql(user.items.pets['Wolf-Base']);
|
||||
expect(message).to.eql(i18n.t('messageLikesFood', {
|
||||
egg: pet.text(),
|
||||
@@ -137,10 +137,10 @@ describe('shared.ops.feed', () => {
|
||||
user.items.pets['Wolf-Spooky'] = 5;
|
||||
user.items.food.Milk = 2;
|
||||
|
||||
let food = content.food.Milk;
|
||||
let pet = content.petInfo['Wolf-Spooky'];
|
||||
const food = content.food.Milk;
|
||||
const pet = content.petInfo['Wolf-Spooky'];
|
||||
|
||||
let [data, message] = feed(user, {params: {pet: 'Wolf-Spooky', food: 'Milk'}});
|
||||
const [data, message] = feed(user, { params: { pet: 'Wolf-Spooky', food: 'Milk' } });
|
||||
expect(data).to.eql(user.items.pets['Wolf-Spooky']);
|
||||
expect(message).to.eql(i18n.t('messageLikesFood', {
|
||||
egg: pet.text(),
|
||||
@@ -155,10 +155,10 @@ describe('shared.ops.feed', () => {
|
||||
user.items.pets['Wolf-Base'] = 5;
|
||||
user.items.food.Milk = 2;
|
||||
|
||||
let food = content.food.Milk;
|
||||
let pet = content.petInfo['Wolf-Base'];
|
||||
const food = content.food.Milk;
|
||||
const pet = content.petInfo['Wolf-Base'];
|
||||
|
||||
let [data, message] = feed(user, {params: {pet: 'Wolf-Base', food: 'Milk'}});
|
||||
const [data, message] = feed(user, { params: { pet: 'Wolf-Base', food: 'Milk' } });
|
||||
expect(data).to.eql(user.items.pets['Wolf-Base']);
|
||||
expect(message).to.eql(i18n.t('messageDontEnjoyFood', {
|
||||
egg: pet.text(),
|
||||
@@ -183,7 +183,7 @@ describe('shared.ops.feed', () => {
|
||||
'Cactus-Base': true,
|
||||
'BearCub-Base': true,
|
||||
};
|
||||
feed(user, {params: {pet: 'Wolf-Spooky', food: 'Milk'}});
|
||||
feed(user, { params: { pet: 'Wolf-Spooky', food: 'Milk' } });
|
||||
expect(user.achievements.allYourBase).to.eql(true);
|
||||
});
|
||||
|
||||
@@ -201,7 +201,7 @@ describe('shared.ops.feed', () => {
|
||||
'Cactus-Desert': true,
|
||||
'BearCub-Desert': true,
|
||||
};
|
||||
feed(user, {params: {pet: 'Wolf-Spooky', food: 'Milk'}});
|
||||
feed(user, { params: { pet: 'Wolf-Spooky', food: 'Milk' } });
|
||||
expect(user.achievements.aridAuthority).to.eql(true);
|
||||
});
|
||||
|
||||
@@ -210,9 +210,9 @@ describe('shared.ops.feed', () => {
|
||||
user.items.food.Milk = 2;
|
||||
user.items.currentPet = 'Wolf-Base';
|
||||
|
||||
let pet = content.petInfo['Wolf-Base'];
|
||||
const pet = content.petInfo['Wolf-Base'];
|
||||
|
||||
let [data, message] = feed(user, {params: {pet: 'Wolf-Base', food: 'Milk'}});
|
||||
const [data, message] = feed(user, { params: { pet: 'Wolf-Base', food: 'Milk' } });
|
||||
expect(data).to.eql(user.items.pets['Wolf-Base']);
|
||||
expect(message).to.eql(i18n.t('messageEvolve', {
|
||||
egg: pet.text(),
|
||||
|
||||
+55
-55
@@ -30,12 +30,12 @@ describe('shared.ops.hatch', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not allow hatching if user lacks specified egg', (done) => {
|
||||
it('does not allow hatching if user lacks specified egg', done => {
|
||||
user.items.eggs.Wolf = 1;
|
||||
user.items.hatchingPotions.Base = 1;
|
||||
user.items.pets = {};
|
||||
try {
|
||||
hatch(user, {params: {egg: 'Dragon', hatchingPotion: 'Base'}});
|
||||
hatch(user, { params: { egg: 'Dragon', hatchingPotion: 'Base' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotFound);
|
||||
expect(err.message).to.equal(i18n.t('messageMissingEggPotion'));
|
||||
@@ -46,12 +46,12 @@ describe('shared.ops.hatch', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not allow hatching if user lacks specified hatching potion', (done) => {
|
||||
it('does not allow hatching if user lacks specified hatching potion', done => {
|
||||
user.items.eggs.Wolf = 1;
|
||||
user.items.hatchingPotions.Base = 1;
|
||||
user.items.pets = {};
|
||||
try {
|
||||
hatch(user, {params: {egg: 'Wolf', hatchingPotion: 'Golden'}});
|
||||
hatch(user, { params: { egg: 'Wolf', hatchingPotion: 'Golden' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotFound);
|
||||
expect(err.message).to.equal(i18n.t('messageMissingEggPotion'));
|
||||
@@ -62,50 +62,50 @@ describe('shared.ops.hatch', () => {
|
||||
}
|
||||
});
|
||||
|
||||
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};
|
||||
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 };
|
||||
try {
|
||||
hatch(user, {params: {egg: 'Wolf', hatchingPotion: 'Base'}});
|
||||
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});
|
||||
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};
|
||||
it('does not allow hatching quest pet egg using premium potion', done => {
|
||||
user.items.eggs = { Cheetah: 1 };
|
||||
user.items.hatchingPotions = { Spooky: 1 };
|
||||
user.items.pets = {};
|
||||
try {
|
||||
hatch(user, {params: {egg: 'Cheetah', hatchingPotion: 'Spooky'}});
|
||||
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});
|
||||
expect(user.items.eggs).to.eql({ Cheetah: 1 });
|
||||
expect(user.items.hatchingPotions).to.eql({ Spooky: 1 });
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('does not allow hatching quest pet egg using wacky potion', (done) => {
|
||||
user.items.eggs = {Bunny: 1};
|
||||
user.items.hatchingPotions = {Veggie: 1};
|
||||
it('does not allow hatching quest pet egg using wacky potion', done => {
|
||||
user.items.eggs = { Bunny: 1 };
|
||||
user.items.hatchingPotions = { Veggie: 1 };
|
||||
user.items.pets = {};
|
||||
try {
|
||||
hatch(user, {params: {egg: 'Bunny', hatchingPotion: 'Veggie'}});
|
||||
hatch(user, { params: { egg: 'Bunny', hatchingPotion: 'Veggie' } });
|
||||
} 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({Bunny: 1});
|
||||
expect(user.items.hatchingPotions).to.eql({Veggie: 1});
|
||||
expect(user.items.eggs).to.eql({ Bunny: 1 });
|
||||
expect(user.items.hatchingPotions).to.eql({ Veggie: 1 });
|
||||
done();
|
||||
}
|
||||
});
|
||||
@@ -113,51 +113,51 @@ describe('shared.ops.hatch', () => {
|
||||
|
||||
context('successful hatching', () => {
|
||||
it('hatches a basic pet', () => {
|
||||
user.items.eggs = {Wolf: 1};
|
||||
user.items.hatchingPotions = {Base: 1};
|
||||
user.items.eggs = { Wolf: 1 };
|
||||
user.items.hatchingPotions = { Base: 1 };
|
||||
user.items.pets = {};
|
||||
let [data, message] = hatch(user, {params: {egg: 'Wolf', hatchingPotion: 'Base'}});
|
||||
const [data, message] = hatch(user, { params: { egg: 'Wolf', hatchingPotion: 'Base' } });
|
||||
expect(message).to.equal(i18n.t('messageHatched'));
|
||||
expect(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});
|
||||
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.eggs = { Cheetah: 1 };
|
||||
user.items.hatchingPotions = { Base: 1 };
|
||||
user.items.pets = {};
|
||||
let [data, message] = hatch(user, {params: {egg: 'Cheetah', hatchingPotion: 'Base'}});
|
||||
const [data, message] = hatch(user, { params: { egg: 'Cheetah', hatchingPotion: 'Base' } });
|
||||
expect(message).to.equal(i18n.t('messageHatched'));
|
||||
expect(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});
|
||||
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.eggs = { Wolf: 1 };
|
||||
user.items.hatchingPotions = { Spooky: 1 };
|
||||
user.items.pets = {};
|
||||
let [data, message] = hatch(user, {params: {egg: 'Wolf', hatchingPotion: 'Spooky'}});
|
||||
const [data, message] = hatch(user, { params: { egg: 'Wolf', hatchingPotion: 'Spooky' } });
|
||||
expect(message).to.equal(i18n.t('messageHatched'));
|
||||
expect(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});
|
||||
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 [data, message] = hatch(user, {params: {egg: 'Wolf', hatchingPotion: 'Base'}});
|
||||
user.items.eggs = { Wolf: 1 };
|
||||
user.items.hatchingPotions = { Base: 1 };
|
||||
user.items.pets = { 'Wolf-Base': -1 };
|
||||
const [data, message] = hatch(user, { params: { egg: 'Wolf', hatchingPotion: 'Base' } });
|
||||
expect(message).to.eql(i18n.t('messageHatched'));
|
||||
expect(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});
|
||||
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('awards Back to Basics achievement', () => {
|
||||
@@ -172,9 +172,9 @@ describe('shared.ops.hatch', () => {
|
||||
'Cactus-Base': 15,
|
||||
'BearCub-Base': 5,
|
||||
};
|
||||
user.items.eggs = {Wolf: 1};
|
||||
user.items.hatchingPotions = {Spooky: 1};
|
||||
hatch(user, {params: {egg: 'Wolf', hatchingPotion: 'Spooky'}});
|
||||
user.items.eggs = { Wolf: 1 };
|
||||
user.items.hatchingPotions = { Spooky: 1 };
|
||||
hatch(user, { params: { egg: 'Wolf', hatchingPotion: 'Spooky' } });
|
||||
expect(user.achievements.backToBasics).to.eql(true);
|
||||
});
|
||||
|
||||
@@ -190,9 +190,9 @@ describe('shared.ops.hatch', () => {
|
||||
'Cactus-Desert': 15,
|
||||
'BearCub-Desert': 5,
|
||||
};
|
||||
user.items.eggs = {Wolf: 1};
|
||||
user.items.hatchingPotions = {Spooky: 1};
|
||||
hatch(user, {params: {egg: 'Wolf', hatchingPotion: 'Spooky'}});
|
||||
user.items.eggs = { Wolf: 1 };
|
||||
user.items.hatchingPotions = { Spooky: 1 };
|
||||
hatch(user, { params: { egg: 'Wolf', hatchingPotion: 'Spooky' } });
|
||||
expect(user.achievements.dustDevil).to.eql(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -15,7 +15,7 @@ describe('shared.ops.openMysteryItem', () => {
|
||||
user = generateUser();
|
||||
});
|
||||
|
||||
it('returns error when item key is empty', (done) => {
|
||||
it('returns error when item key is empty', done => {
|
||||
try {
|
||||
openMysteryItem(user);
|
||||
} catch (err) {
|
||||
@@ -26,17 +26,17 @@ describe('shared.ops.openMysteryItem', () => {
|
||||
});
|
||||
|
||||
it('opens mystery item', () => {
|
||||
let mysteryItemKey = 'eyewear_special_summerRogue';
|
||||
const mysteryItemKey = 'eyewear_special_summerRogue';
|
||||
|
||||
user.purchased.plan.mysteryItems = [mysteryItemKey];
|
||||
user.notifications.push({type: 'NEW_MYSTERY_ITEMS', data: {items: [mysteryItemKey]}});
|
||||
user.notifications.push({ type: 'NEW_MYSTERY_ITEMS', data: { items: [mysteryItemKey] } });
|
||||
expect(user.notifications.length).to.equal(1);
|
||||
|
||||
let [data, message] = openMysteryItem(user);
|
||||
const [data, message] = openMysteryItem(user);
|
||||
|
||||
expect(user.items.gear.owned[mysteryItemKey]).to.be.true;
|
||||
expect(message).to.equal(i18n.t('mysteryItemOpened'));
|
||||
let item = _.cloneDeep(content.gear.flat[mysteryItemKey]);
|
||||
const item = _.cloneDeep(content.gear.flat[mysteryItemKey]);
|
||||
item.text = content.gear.flat[mysteryItemKey].text();
|
||||
expect(data).to.eql(item);
|
||||
expect(user.notifications.length).to.equal(0);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../helpers/common.helper';
|
||||
import {addPinnedGear} from '../../../website/common/script/ops/pinnedGearUtils';
|
||||
import { addPinnedGear } from '../../../website/common/script/ops/pinnedGearUtils';
|
||||
|
||||
describe('shared.ops.pinnedGearUtils.addPinnedGear', () => {
|
||||
let user;
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
|
||||
describe('shared.ops.readCard', () => {
|
||||
let user;
|
||||
let cardType = 'greeting';
|
||||
const cardType = 'greeting';
|
||||
|
||||
beforeEach(() => {
|
||||
user = generateUser();
|
||||
@@ -18,7 +18,7 @@ describe('shared.ops.readCard', () => {
|
||||
user.flags.cardReceived = true;
|
||||
});
|
||||
|
||||
it('returns an error when cardType is not provided', (done) => {
|
||||
it('returns an error when cardType is not provided', done => {
|
||||
try {
|
||||
readCard(user);
|
||||
} catch (err) {
|
||||
@@ -28,9 +28,9 @@ describe('shared.ops.readCard', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('returns an error when unknown cardType is provided', (done) => {
|
||||
it('returns an error when unknown cardType is provided', done => {
|
||||
try {
|
||||
readCard(user, {params: {cardType: 'randomCardType'}});
|
||||
readCard(user, { params: { cardType: 'randomCardType' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('cardTypeNotAllowed'));
|
||||
@@ -41,13 +41,13 @@ describe('shared.ops.readCard', () => {
|
||||
it('reads a card', () => {
|
||||
user.notifications.push({
|
||||
type: 'CARD_RECEIVED',
|
||||
data: {card: cardType},
|
||||
data: { card: cardType },
|
||||
});
|
||||
const initialNotificationNuber = user.notifications.length;
|
||||
|
||||
let [, message] = readCard(user, {params: {cardType: 'greeting'}});
|
||||
const [, message] = readCard(user, { params: { cardType: 'greeting' } });
|
||||
|
||||
expect(message).to.equal(i18n.t('readCard', {cardType}));
|
||||
expect(message).to.equal(i18n.t('readCard', { cardType }));
|
||||
expect(user.items.special[`${cardType}Received`]).to.be.empty;
|
||||
expect(user.flags.cardReceived).to.be.false;
|
||||
expect(user.notifications.length).to.equal(initialNotificationNuber - 1);
|
||||
|
||||
+19
-17
@@ -14,8 +14,8 @@ import {
|
||||
|
||||
describe('shared.ops.rebirth', () => {
|
||||
let user;
|
||||
let animal = 'Wolf-Base';
|
||||
let userStats = ['per', 'int', 'con', 'str', 'points', 'gp', 'exp', 'mp'];
|
||||
const animal = 'Wolf-Base';
|
||||
const userStats = ['per', 'int', 'con', 'str', 'points', 'gp', 'exp', 'mp'];
|
||||
let tasks = [];
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -24,7 +24,7 @@ describe('shared.ops.rebirth', () => {
|
||||
tasks = [generateHabit(), generateDaily(), generateTodo(), generateReward()];
|
||||
});
|
||||
|
||||
it('returns an error when user balance is too low and user is less than max level', (done) => {
|
||||
it('returns an error when user balance is too low and user is less than max level', done => {
|
||||
user.balance = 0;
|
||||
|
||||
try {
|
||||
@@ -37,7 +37,7 @@ describe('shared.ops.rebirth', () => {
|
||||
});
|
||||
|
||||
it('rebirths a user with enough gems', () => {
|
||||
let [, message] = rebirth(user);
|
||||
const [, message] = rebirth(user);
|
||||
|
||||
expect(message).to.equal(i18n.t('rebirthComplete'));
|
||||
});
|
||||
@@ -46,7 +46,7 @@ describe('shared.ops.rebirth', () => {
|
||||
user.balance = 0;
|
||||
user.stats.lvl = MAX_LEVEL;
|
||||
|
||||
let [, message] = rebirth(user);
|
||||
const [, message] = rebirth(user);
|
||||
|
||||
expect(message).to.equal(i18n.t('rebirthComplete'));
|
||||
expect(user.flags.lastFreeRebirth).to.exist;
|
||||
@@ -56,7 +56,7 @@ describe('shared.ops.rebirth', () => {
|
||||
user.balance = 0;
|
||||
user.stats.lvl = MAX_LEVEL + 1;
|
||||
|
||||
let [, message] = rebirth(user);
|
||||
const [, message] = rebirth(user);
|
||||
|
||||
expect(message).to.equal(i18n.t('rebirthComplete'));
|
||||
});
|
||||
@@ -65,7 +65,7 @@ describe('shared.ops.rebirth', () => {
|
||||
user.stats.lvl = MAX_LEVEL + 1;
|
||||
user.flags.lastFreeRebirth = new Date();
|
||||
|
||||
let [, message] = rebirth(user);
|
||||
const [, message] = rebirth(user);
|
||||
|
||||
expect(message).to.equal(i18n.t('rebirthComplete'));
|
||||
expect(user.balance).to.equal(0);
|
||||
@@ -98,7 +98,7 @@ describe('shared.ops.rebirth', () => {
|
||||
});
|
||||
|
||||
it('resets a user\'s buffs', () => {
|
||||
user.stats.buffs = {test: 'test'};
|
||||
user.stats.buffs = { test: 'test' };
|
||||
|
||||
rebirth(user);
|
||||
|
||||
@@ -123,21 +123,21 @@ describe('shared.ops.rebirth', () => {
|
||||
|
||||
it('resets a user\'s stats', () => {
|
||||
user.stats.class = 'rouge';
|
||||
_.each(userStats, function setUsersStats (value) {
|
||||
_.each(userStats, value => {
|
||||
user.stats[value] = 10;
|
||||
});
|
||||
|
||||
rebirth(user);
|
||||
|
||||
_.each(userStats, function resetUserStats (value) {
|
||||
_.each(userStats, value => {
|
||||
user.stats[value] = 0;
|
||||
});
|
||||
});
|
||||
|
||||
it('retains a user\'s gear', () => {
|
||||
let prevGearEquipped = user.items.gear.equipped;
|
||||
let prevGearCostume = user.items.gear.costume;
|
||||
let prevPrefCostume = user.preferences.costume;
|
||||
const prevGearEquipped = user.items.gear.equipped;
|
||||
const prevGearCostume = user.items.gear.costume;
|
||||
const prevPrefCostume = user.preferences.costume;
|
||||
|
||||
rebirth(user);
|
||||
|
||||
@@ -148,7 +148,7 @@ describe('shared.ops.rebirth', () => {
|
||||
|
||||
it('retains a user\'s gear owned', () => {
|
||||
user.items.gear.owned.weapon_warrior_1 = true; // eslint-disable-line camelcase
|
||||
let prevGearOwned = user.items.gear.owned;
|
||||
const prevGearOwned = user.items.gear.owned;
|
||||
|
||||
rebirth(user);
|
||||
|
||||
@@ -176,7 +176,7 @@ describe('shared.ops.rebirth', () => {
|
||||
user.flags.dropsEnabled = true;
|
||||
user.flags.classSelected = true;
|
||||
user.flags.rebirthEnabled = true;
|
||||
user.flags.levelDrops = {test: 'test'};
|
||||
user.flags.levelDrops = { test: 'test' };
|
||||
|
||||
rebirth(user);
|
||||
|
||||
@@ -228,7 +228,8 @@ describe('shared.ops.rebirth', () => {
|
||||
it('always increments rebirth achievements when level is MAX_LEVEL', () => {
|
||||
user.stats.lvl = MAX_LEVEL;
|
||||
user.achievements.rebirths = 1;
|
||||
user.achievements.rebirthLevel = MAX_LEVEL + 1; // this value is not actually possible (actually capped at MAX_LEVEL) but makes a good test
|
||||
// this value is not actually possible (actually capped at MAX_LEVEL) but makes a good test
|
||||
user.achievements.rebirthLevel = MAX_LEVEL + 1;
|
||||
|
||||
rebirth(user);
|
||||
|
||||
@@ -239,7 +240,8 @@ describe('shared.ops.rebirth', () => {
|
||||
it('always increments rebirth achievements when level is greater than MAX_LEVEL', () => {
|
||||
user.stats.lvl = MAX_LEVEL + 1;
|
||||
user.achievements.rebirths = 1;
|
||||
user.achievements.rebirthLevel = MAX_LEVEL + 2; // this value is not actually possible (actually capped at MAX_LEVEL) but makes a good test
|
||||
// this value is not actually possible (actually capped at MAX_LEVEL) but makes a good test
|
||||
user.achievements.rebirthLevel = MAX_LEVEL + 2;
|
||||
|
||||
rebirth(user);
|
||||
|
||||
|
||||
@@ -10,19 +10,19 @@ import {
|
||||
|
||||
describe('shared.ops.releaseBoth', () => {
|
||||
let user;
|
||||
let animal = 'Wolf-Base';
|
||||
const animal = 'Wolf-Base';
|
||||
|
||||
beforeEach(() => {
|
||||
user = generateUser();
|
||||
for (let p in content.pets) {
|
||||
Object.keys(content.pets).forEach(p => {
|
||||
user.items.pets[p] = content.pets[p];
|
||||
user.items.pets[p] = 5;
|
||||
}
|
||||
});
|
||||
|
||||
for (let m in content.pets) {
|
||||
Object.keys(content.pets).forEach(m => {
|
||||
user.items.mounts[m] = content.pets[m];
|
||||
user.items.mounts[m] = true;
|
||||
}
|
||||
});
|
||||
|
||||
user.items.currentMount = animal;
|
||||
user.items.currentPet = animal;
|
||||
@@ -30,7 +30,7 @@ describe('shared.ops.releaseBoth', () => {
|
||||
user.achievements.triadBingo = true;
|
||||
});
|
||||
|
||||
xit('returns an error when user balance is too low and user does not have triadBingo', (done) => {
|
||||
xit('returns an error when user balance is too low and user does not have triadBingo', done => {
|
||||
user.balance = 0;
|
||||
|
||||
try {
|
||||
@@ -42,7 +42,7 @@ describe('shared.ops.releaseBoth', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('returns an error when user does not have all pets', (done) => {
|
||||
it('returns an error when user does not have all pets', done => {
|
||||
const petKeys = Object.keys(user.items.pets);
|
||||
delete user.items.pets[petKeys[0]];
|
||||
|
||||
@@ -59,7 +59,7 @@ describe('shared.ops.releaseBoth', () => {
|
||||
});
|
||||
|
||||
it('grants triad bingo with gems', () => {
|
||||
let message = releaseBoth(user)[1];
|
||||
const message = releaseBoth(user)[1];
|
||||
|
||||
expect(message).to.equal(i18n.t('mountsAndPetsReleased'));
|
||||
expect(user.achievements.triadBingoCount).to.equal(1);
|
||||
@@ -70,23 +70,23 @@ describe('shared.ops.releaseBoth', () => {
|
||||
user.achievements.triadBingo = 1;
|
||||
user.achievements.triadBingoCount = 1;
|
||||
|
||||
let message = releaseBoth(user)[1];
|
||||
const message = releaseBoth(user)[1];
|
||||
|
||||
expect(message).to.equal(i18n.t('mountsAndPetsReleased'));
|
||||
expect(user.achievements.triadBingoCount).to.equal(2);
|
||||
});
|
||||
|
||||
it('does not grant triad bingo if any pet has not been previously found', () => {
|
||||
let triadBingoCountBeforeRelease = user.achievements.triadBingoCount;
|
||||
const triadBingoCountBeforeRelease = user.achievements.triadBingoCount;
|
||||
user.items.pets[animal] = -1;
|
||||
let message = releaseBoth(user)[1];
|
||||
const message = releaseBoth(user)[1];
|
||||
|
||||
expect(message).to.equal(i18n.t('mountsAndPetsReleased'));
|
||||
expect(user.achievements.triadBingoCount).to.equal(triadBingoCountBeforeRelease);
|
||||
});
|
||||
|
||||
it('releases pets', () => {
|
||||
let message = releaseBoth(user)[1];
|
||||
const message = releaseBoth(user)[1];
|
||||
|
||||
expect(message).to.equal(i18n.t('mountsAndPetsReleased'));
|
||||
expect(user.items.pets[animal]).to.equal(0);
|
||||
@@ -94,7 +94,7 @@ describe('shared.ops.releaseBoth', () => {
|
||||
});
|
||||
|
||||
it('does not increment beastMasterCount if any pet is level 0 (released)', () => {
|
||||
let beastMasterCountBeforeRelease = user.achievements.beastMasterCount;
|
||||
const beastMasterCountBeforeRelease = user.achievements.beastMasterCount;
|
||||
user.items.pets[animal] = 0;
|
||||
try {
|
||||
releaseBoth(user);
|
||||
@@ -104,7 +104,7 @@ describe('shared.ops.releaseBoth', () => {
|
||||
});
|
||||
|
||||
it('does not increment beastMasterCount if any pet is missing (null)', () => {
|
||||
let beastMasterCountBeforeRelease = user.achievements.beastMasterCount;
|
||||
const beastMasterCountBeforeRelease = user.achievements.beastMasterCount;
|
||||
user.items.pets[animal] = null;
|
||||
|
||||
try {
|
||||
@@ -115,7 +115,7 @@ describe('shared.ops.releaseBoth', () => {
|
||||
});
|
||||
|
||||
it('does not increment beastMasterCount if any pet is missing (undefined)', () => {
|
||||
let beastMasterCountBeforeRelease = user.achievements.beastMasterCount;
|
||||
const beastMasterCountBeforeRelease = user.achievements.beastMasterCount;
|
||||
delete user.items.pets[animal];
|
||||
|
||||
try {
|
||||
@@ -126,14 +126,14 @@ describe('shared.ops.releaseBoth', () => {
|
||||
});
|
||||
|
||||
it('releases mounts', () => {
|
||||
let message = releaseBoth(user)[1];
|
||||
const message = releaseBoth(user)[1];
|
||||
|
||||
expect(message).to.equal(i18n.t('mountsAndPetsReleased'));
|
||||
expect(user.items.mounts[animal]).to.equal(null);
|
||||
});
|
||||
|
||||
it('does not increase mountMasterCount achievement if mount is missing (null)', () => {
|
||||
let mountMasterCountBeforeRelease = user.achievements.mountMasterCount;
|
||||
const mountMasterCountBeforeRelease = user.achievements.mountMasterCount;
|
||||
user.items.mounts[animal] = null;
|
||||
|
||||
try {
|
||||
@@ -144,7 +144,7 @@ describe('shared.ops.releaseBoth', () => {
|
||||
});
|
||||
|
||||
it('does not increase mountMasterCount achievement if mount is missing (undefined)', () => {
|
||||
let mountMasterCountBeforeRelease = user.achievements.mountMasterCount;
|
||||
const mountMasterCountBeforeRelease = user.achievements.mountMasterCount;
|
||||
delete user.items.mounts[animal];
|
||||
|
||||
try {
|
||||
@@ -155,7 +155,7 @@ describe('shared.ops.releaseBoth', () => {
|
||||
});
|
||||
|
||||
it('removes drop currentPet', () => {
|
||||
let petInfo = content.petInfo[user.items.currentPet];
|
||||
const petInfo = content.petInfo[user.items.currentPet];
|
||||
expect(petInfo.type).to.equal('drop');
|
||||
releaseBoth(user);
|
||||
|
||||
@@ -164,7 +164,7 @@ describe('shared.ops.releaseBoth', () => {
|
||||
});
|
||||
|
||||
it('removes drop currentMount', () => {
|
||||
let mountInfo = content.mountInfo[user.items.currentMount];
|
||||
const mountInfo = content.mountInfo[user.items.currentMount];
|
||||
expect(mountInfo.type).to.equal('drop');
|
||||
releaseBoth(user);
|
||||
|
||||
@@ -172,15 +172,15 @@ describe('shared.ops.releaseBoth', () => {
|
||||
});
|
||||
|
||||
it('leaves non-drop pets and mounts equipped', () => {
|
||||
let questAnimal = 'Gryphon-Base';
|
||||
const questAnimal = 'Gryphon-Base';
|
||||
user.items.currentMount = questAnimal;
|
||||
user.items.currentPet = questAnimal;
|
||||
user.items.pets[questAnimal] = 5;
|
||||
user.items.mounts[questAnimal] = true;
|
||||
|
||||
let petInfo = content.petInfo[user.items.currentPet];
|
||||
const petInfo = content.petInfo[user.items.currentPet];
|
||||
expect(petInfo.type).to.not.equal('drop');
|
||||
let mountInfo = content.mountInfo[user.items.currentMount];
|
||||
const mountInfo = content.mountInfo[user.items.currentMount];
|
||||
expect(mountInfo.type).to.not.equal('drop');
|
||||
|
||||
releaseBoth(user);
|
||||
|
||||
@@ -10,20 +10,20 @@ import {
|
||||
|
||||
describe('shared.ops.releaseMounts', () => {
|
||||
let user;
|
||||
let animal = 'Wolf-Base';
|
||||
const animal = 'Wolf-Base';
|
||||
|
||||
beforeEach(() => {
|
||||
user = generateUser();
|
||||
for (let k in content.pets) {
|
||||
Object.keys(content.pets).forEach(k => {
|
||||
user.items.mounts[k] = content.pets[k];
|
||||
user.items.mounts[k] = true;
|
||||
}
|
||||
});
|
||||
|
||||
user.items.currentMount = animal;
|
||||
user.balance = 1;
|
||||
});
|
||||
|
||||
it('returns an error when user balance is too low', (done) => {
|
||||
it('returns an error when user balance is too low', done => {
|
||||
user.balance = 0;
|
||||
|
||||
try {
|
||||
@@ -35,7 +35,7 @@ describe('shared.ops.releaseMounts', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('returns an error when user does not have all pets', (done) => {
|
||||
it('returns an error when user does not have all pets', done => {
|
||||
const mountsKeys = Object.keys(user.items.mounts);
|
||||
delete user.items.mounts[mountsKeys[0]];
|
||||
|
||||
@@ -49,14 +49,14 @@ describe('shared.ops.releaseMounts', () => {
|
||||
});
|
||||
|
||||
it('releases mounts', () => {
|
||||
let message = releaseMounts(user)[1];
|
||||
const message = releaseMounts(user)[1];
|
||||
|
||||
expect(message).to.equal(i18n.t('mountsReleased'));
|
||||
expect(user.items.mounts[animal]).to.equal(null);
|
||||
});
|
||||
|
||||
it('removes drop currentMount', () => {
|
||||
let mountInfo = content.mountInfo[user.items.currentMount];
|
||||
const mountInfo = content.mountInfo[user.items.currentMount];
|
||||
expect(mountInfo.type).to.equal('drop');
|
||||
releaseMounts(user);
|
||||
|
||||
@@ -64,11 +64,11 @@ describe('shared.ops.releaseMounts', () => {
|
||||
});
|
||||
|
||||
it('leaves non-drop mount equipped', () => {
|
||||
let questAnimal = 'Gryphon-Base';
|
||||
const questAnimal = 'Gryphon-Base';
|
||||
user.items.currentMount = questAnimal;
|
||||
user.items.mounts[questAnimal] = true;
|
||||
|
||||
let mountInfo = content.mountInfo[user.items.currentMount];
|
||||
const mountInfo = content.mountInfo[user.items.currentMount];
|
||||
expect(mountInfo.type).to.not.equal('drop');
|
||||
releaseMounts(user);
|
||||
|
||||
@@ -81,7 +81,7 @@ describe('shared.ops.releaseMounts', () => {
|
||||
});
|
||||
|
||||
it('does not increase mountMasterCount achievement if mount is missing (null)', () => {
|
||||
let mountMasterCountBeforeRelease = user.achievements.mountMasterCount;
|
||||
const mountMasterCountBeforeRelease = user.achievements.mountMasterCount;
|
||||
user.items.mounts[animal] = null;
|
||||
|
||||
try {
|
||||
@@ -92,7 +92,7 @@ describe('shared.ops.releaseMounts', () => {
|
||||
});
|
||||
|
||||
it('does not increase mountMasterCount achievement if mount is missing (undefined)', () => {
|
||||
let mountMasterCountBeforeRelease = user.achievements.mountMasterCount;
|
||||
const mountMasterCountBeforeRelease = user.achievements.mountMasterCount;
|
||||
delete user.items.mounts[animal];
|
||||
|
||||
try {
|
||||
|
||||
@@ -10,20 +10,20 @@ import {
|
||||
|
||||
describe('shared.ops.releasePets', () => {
|
||||
let user;
|
||||
let animal = 'Wolf-Base';
|
||||
const animal = 'Wolf-Base';
|
||||
|
||||
beforeEach(() => {
|
||||
user = generateUser();
|
||||
for (let k in content.pets) {
|
||||
Object.keys(content.pets).forEach(k => {
|
||||
user.items.pets[k] = content.pets[k];
|
||||
user.items.pets[k] = 5;
|
||||
}
|
||||
});
|
||||
|
||||
user.items.currentPet = animal;
|
||||
user.balance = 1;
|
||||
});
|
||||
|
||||
it('returns an error when user balance is too low', (done) => {
|
||||
it('returns an error when user balance is too low', done => {
|
||||
user.balance = 0;
|
||||
|
||||
try {
|
||||
@@ -35,7 +35,7 @@ describe('shared.ops.releasePets', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('returns an error when user does not have all pets', (done) => {
|
||||
it('returns an error when user does not have all pets', done => {
|
||||
const petKeys = Object.keys(user.items.pets);
|
||||
delete user.items.pets[petKeys[0]];
|
||||
|
||||
@@ -49,14 +49,14 @@ describe('shared.ops.releasePets', () => {
|
||||
});
|
||||
|
||||
it('releases pets', () => {
|
||||
let message = releasePets(user)[1];
|
||||
const message = releasePets(user)[1];
|
||||
|
||||
expect(message).to.equal(i18n.t('petsReleased'));
|
||||
expect(user.items.pets[animal]).to.equal(0);
|
||||
});
|
||||
|
||||
it('removes drop currentPet', () => {
|
||||
let petInfo = content.petInfo[user.items.currentPet];
|
||||
const petInfo = content.petInfo[user.items.currentPet];
|
||||
expect(petInfo.type).to.equal('drop');
|
||||
releasePets(user);
|
||||
|
||||
@@ -64,11 +64,11 @@ describe('shared.ops.releasePets', () => {
|
||||
});
|
||||
|
||||
it('leaves non-drop pets equipped', () => {
|
||||
let questAnimal = 'Gryphon-Base';
|
||||
const questAnimal = 'Gryphon-Base';
|
||||
user.items.currentPet = questAnimal;
|
||||
user.items.pets[questAnimal] = 5;
|
||||
|
||||
let petInfo = content.petInfo[user.items.currentPet];
|
||||
const petInfo = content.petInfo[user.items.currentPet];
|
||||
expect(petInfo.type).to.not.equal('drop');
|
||||
releasePets(user);
|
||||
|
||||
@@ -99,7 +99,7 @@ describe('shared.ops.releasePets', () => {
|
||||
});
|
||||
|
||||
it('does not increment beastMasterCount if any pet is missing (null)', () => {
|
||||
let beastMasterCountBeforeRelease = user.achievements.beastMasterCount;
|
||||
const beastMasterCountBeforeRelease = user.achievements.beastMasterCount;
|
||||
user.items.pets[animal] = null;
|
||||
|
||||
try {
|
||||
@@ -110,7 +110,7 @@ describe('shared.ops.releasePets', () => {
|
||||
});
|
||||
|
||||
it('does not increment beastMasterCount if any pet is missing (undefined)', () => {
|
||||
let beastMasterCountBeforeRelease = user.achievements.beastMasterCount;
|
||||
const beastMasterCountBeforeRelease = user.achievements.beastMasterCount;
|
||||
delete user.items.pets[animal];
|
||||
|
||||
try {
|
||||
|
||||
@@ -19,7 +19,7 @@ describe('shared.ops.reroll', () => {
|
||||
tasks = [generateDaily(), generateReward()];
|
||||
});
|
||||
|
||||
it('returns an error when user balance is too low', (done) => {
|
||||
it('returns an error when user balance is too low', done => {
|
||||
user.balance = 0;
|
||||
|
||||
try {
|
||||
@@ -32,7 +32,7 @@ describe('shared.ops.reroll', () => {
|
||||
});
|
||||
|
||||
it('rerolls a user with enough gems', () => {
|
||||
let [, message] = reroll(user);
|
||||
const [, message] = reroll(user);
|
||||
|
||||
expect(message).to.equal(i18n.t('fortifyComplete'));
|
||||
});
|
||||
|
||||
@@ -16,10 +16,10 @@ describe('shared.ops.reset', () => {
|
||||
user = generateUser();
|
||||
user.balance = 2;
|
||||
|
||||
let habit = generateHabit();
|
||||
let todo = generateTodo();
|
||||
let daily = generateDaily();
|
||||
let reward = generateReward();
|
||||
const habit = generateHabit();
|
||||
const todo = generateTodo();
|
||||
const daily = generateDaily();
|
||||
const reward = generateReward();
|
||||
|
||||
user.tasksOrder.habits = [habit._id];
|
||||
user.tasksOrder.todos = [todo._id];
|
||||
@@ -31,7 +31,7 @@ describe('shared.ops.reset', () => {
|
||||
|
||||
|
||||
it('resets a user', () => {
|
||||
let [, message] = reset(user);
|
||||
const [, message] = reset(user);
|
||||
|
||||
expect(message).to.equal(i18n.t('resetComplete'));
|
||||
});
|
||||
|
||||
+26
-28
@@ -18,7 +18,7 @@ describe('shared.ops.revive', () => {
|
||||
user.stats.hp = 0;
|
||||
});
|
||||
|
||||
it('returns an error when user is not dead', (done) => {
|
||||
it('returns an error when user is not dead', done => {
|
||||
user.stats.hp = 10;
|
||||
|
||||
try {
|
||||
@@ -56,28 +56,26 @@ describe('shared.ops.revive', () => {
|
||||
});
|
||||
|
||||
it('it decreases a random stat from str, con, per, int by one', () => {
|
||||
let stats = ['str', 'con', 'per', 'int'];
|
||||
const stats = ['str', 'con', 'per', 'int'];
|
||||
|
||||
_.each(stats, (s) => {
|
||||
_.each(stats, s => {
|
||||
user.stats[s] = 1;
|
||||
});
|
||||
|
||||
revive(user);
|
||||
|
||||
let statSum = _.reduce(stats, (m, k) => {
|
||||
return m + user.stats[k];
|
||||
}, 0);
|
||||
const statSum = _.reduce(stats, (m, k) => m + user.stats[k], 0);
|
||||
|
||||
expect(statSum).to.equal(3);
|
||||
});
|
||||
|
||||
it('removes a random item from user gear owned', () => {
|
||||
let weaponKey = 'weapon_warrior_0';
|
||||
const weaponKey = 'weapon_warrior_0';
|
||||
user.items.gear.owned[weaponKey] = true;
|
||||
|
||||
let [, message] = revive(user);
|
||||
const [, message] = revive(user);
|
||||
|
||||
expect(message).to.equal(i18n.t('messageLostItem', { itemText: content.gear.flat[weaponKey].text()}));
|
||||
expect(message).to.equal(i18n.t('messageLostItem', { itemText: content.gear.flat[weaponKey].text() }));
|
||||
expect(user.items.gear.owned[weaponKey]).to.be.false;
|
||||
});
|
||||
|
||||
@@ -96,67 +94,67 @@ describe('shared.ops.revive', () => {
|
||||
weapon_warrior_0: true,
|
||||
};
|
||||
|
||||
let weaponKey = 'weapon_warrior_0';
|
||||
const weaponKey = 'weapon_warrior_0';
|
||||
|
||||
let [, message] = revive(user);
|
||||
const [, message] = revive(user);
|
||||
|
||||
expect(message).to.equal(i18n.t('messageLostItem', { itemText: content.gear.flat[weaponKey].text()}));
|
||||
expect(message).to.equal(i18n.t('messageLostItem', { itemText: content.gear.flat[weaponKey].text() }));
|
||||
expect(user.items.gear.owned[weaponKey]).to.be.false;
|
||||
});
|
||||
|
||||
it('does not remove items of a different class', () => {
|
||||
let weaponKey = 'weapon_wizard_1';
|
||||
const weaponKey = 'weapon_wizard_1';
|
||||
user.items.gear.owned[weaponKey] = true;
|
||||
|
||||
let [, message] = revive(user);
|
||||
const [, message] = revive(user);
|
||||
|
||||
expect(message).to.equal('');
|
||||
expect(user.items.gear.owned[weaponKey]).to.be.true;
|
||||
});
|
||||
|
||||
it('removes "special" items', () => {
|
||||
let weaponKey = 'weapon_special_1';
|
||||
const weaponKey = 'weapon_special_1';
|
||||
user.items.gear.owned[weaponKey] = true;
|
||||
|
||||
let [, message] = revive(user);
|
||||
const [, message] = revive(user);
|
||||
|
||||
expect(message).to.equal(i18n.t('messageLostItem', { itemText: content.gear.flat[weaponKey].text()}));
|
||||
expect(message).to.equal(i18n.t('messageLostItem', { itemText: content.gear.flat[weaponKey].text() }));
|
||||
expect(user.items.gear.owned[weaponKey]).to.be.false;
|
||||
});
|
||||
|
||||
it('removes "armoire" items', () => {
|
||||
let weaponKey = 'armor_armoire_goldenToga';
|
||||
const weaponKey = 'armor_armoire_goldenToga';
|
||||
user.items.gear.owned[weaponKey] = true;
|
||||
|
||||
let [, message] = revive(user);
|
||||
const [, message] = revive(user);
|
||||
|
||||
expect(message).to.equal(i18n.t('messageLostItem', { itemText: content.gear.flat[weaponKey].text()}));
|
||||
expect(message).to.equal(i18n.t('messageLostItem', { itemText: content.gear.flat[weaponKey].text() }));
|
||||
expect(user.items.gear.owned[weaponKey]).to.be.false;
|
||||
});
|
||||
|
||||
it('dequips lost item from user if user had it equipped', () => {
|
||||
let weaponKey = 'weapon_warrior_0';
|
||||
let itemToLose = content.gear.flat[weaponKey];
|
||||
const weaponKey = 'weapon_warrior_0';
|
||||
const itemToLose = content.gear.flat[weaponKey];
|
||||
|
||||
user.items.gear.owned[weaponKey] = true;
|
||||
user.items.gear.equipped[itemToLose.type] = itemToLose.key;
|
||||
|
||||
let [, message] = revive(user);
|
||||
const [, message] = revive(user);
|
||||
|
||||
expect(message).to.equal(i18n.t('messageLostItem', { itemText: itemToLose.text()}));
|
||||
expect(message).to.equal(i18n.t('messageLostItem', { itemText: itemToLose.text() }));
|
||||
expect(user.items.gear.equipped[itemToLose.type]).to.equal(`${itemToLose.type}_base_0`);
|
||||
});
|
||||
|
||||
it('dequips lost item from user costume if user was using it in costume', () => {
|
||||
let weaponKey = 'weapon_warrior_0';
|
||||
let itemToLose = content.gear.flat[weaponKey];
|
||||
const weaponKey = 'weapon_warrior_0';
|
||||
const itemToLose = content.gear.flat[weaponKey];
|
||||
|
||||
user.items.gear.owned[weaponKey] = true;
|
||||
user.items.gear.costume[itemToLose.type] = itemToLose.key;
|
||||
|
||||
let [, message] = revive(user);
|
||||
const [, message] = revive(user);
|
||||
|
||||
expect(message).to.equal(i18n.t('messageLostItem', { itemText: itemToLose.text()}));
|
||||
expect(message).to.equal(i18n.t('messageLostItem', { itemText: itemToLose.text() }));
|
||||
expect(user.items.gear.costume[itemToLose.type]).to.equal(`${itemToLose.type}_base_0`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,11 +13,11 @@ import {
|
||||
} from '../../../website/common/script/libs/errors';
|
||||
import crit from '../../../website/common/script/fns/crit';
|
||||
|
||||
let EPSILON = 0.0001; // negligible distance between datapoints
|
||||
const EPSILON = 0.0001; // negligible distance between datapoints
|
||||
|
||||
let beforeAfter = () => {
|
||||
let beforeUser = generateUser();
|
||||
let afterUser = _.cloneDeep(beforeUser);
|
||||
const beforeAfter = () => {
|
||||
const beforeUser = generateUser();
|
||||
const afterUser = _.cloneDeep(beforeUser);
|
||||
|
||||
return {
|
||||
beforeUser,
|
||||
@@ -25,7 +25,7 @@ let beforeAfter = () => {
|
||||
};
|
||||
};
|
||||
|
||||
let expectGainedPoints = (beforeUser, afterUser, beforeTask, afterTask) => {
|
||||
const expectGainedPoints = (beforeUser, afterUser, beforeTask, afterTask) => {
|
||||
expect(afterUser.stats.hp).to.eql(50);
|
||||
expect(afterUser.stats.exp).to.be.greaterThan(beforeUser.stats.exp);
|
||||
expect(afterUser.stats.gp).to.be.greaterThan(beforeUser.stats.gp);
|
||||
@@ -35,15 +35,15 @@ let expectGainedPoints = (beforeUser, afterUser, beforeTask, afterTask) => {
|
||||
}
|
||||
};
|
||||
|
||||
let expectClosePoints = (beforeUser, afterUser, beforeTask, task) => {
|
||||
const expectClosePoints = (beforeUser, afterUser, beforeTask, task) => {
|
||||
expect(Math.abs(afterUser.stats.exp - beforeUser.stats.exp)).to.be.lessThan(EPSILON);
|
||||
expect(Math.abs(afterUser.stats.gp - beforeUser.stats.gp)).to.be.lessThan(EPSILON);
|
||||
expect(Math.abs(task.value - beforeTask.value)).to.be.lessThan(EPSILON);
|
||||
};
|
||||
|
||||
function expectRoughlyEqualDates (date1, date2) {
|
||||
date1 = date1.valueOf();
|
||||
date2 = date2.valueOf();
|
||||
date1 = date1.valueOf(); // eslint-disable-line no-param-reassign
|
||||
date2 = date2.valueOf(); // eslint-disable-line no-param-reassign
|
||||
expect(date1).to.be.within(date2 - 100, date2 + 100);
|
||||
}
|
||||
|
||||
@@ -54,8 +54,8 @@ describe('shared.ops.scoreTask', () => {
|
||||
ref = beforeAfter();
|
||||
});
|
||||
|
||||
it('throws an error when scoring a reward if user does not have enough gold', (done) => {
|
||||
let reward = generateReward({ userId: ref.afterUser._id, text: 'some reward', value: 100 });
|
||||
it('throws an error when scoring a reward if user does not have enough gold', done => {
|
||||
const reward = generateReward({ userId: ref.afterUser._id, text: 'some reward', value: 100 });
|
||||
try {
|
||||
scoreTask({ user: ref.afterUser, task: reward });
|
||||
} catch (err) {
|
||||
@@ -66,14 +66,14 @@ describe('shared.ops.scoreTask', () => {
|
||||
});
|
||||
|
||||
it('completes when the task direction is up', () => {
|
||||
let task = generateTodo({ userId: ref.afterUser._id, text: 'todo to complete', cron: false });
|
||||
const task = generateTodo({ userId: ref.afterUser._id, text: 'todo to complete', cron: false });
|
||||
scoreTask({ user: ref.afterUser, task, direction: 'up' });
|
||||
expect(task.completed).to.eql(true);
|
||||
expectRoughlyEqualDates(task.dateCompleted, new Date());
|
||||
});
|
||||
|
||||
it('uncompletes when the task direction is down', () => {
|
||||
let task = generateTodo({ userId: ref.afterUser._id, text: 'todo to complete', cron: false });
|
||||
const task = generateTodo({ userId: ref.afterUser._id, text: 'todo to complete', cron: false });
|
||||
scoreTask({ user: ref.afterUser, task, direction: 'down' });
|
||||
expect(task.completed).to.eql(false);
|
||||
expect(task.dateCompleted).to.not.exist;
|
||||
@@ -88,19 +88,23 @@ describe('shared.ops.scoreTask', () => {
|
||||
});
|
||||
|
||||
it('works', () => {
|
||||
let delta1, delta2, delta3;
|
||||
|
||||
delta1 = scoreTask({ user: ref.afterUser, task: habit, direction: 'up', times: 5, cron: false });
|
||||
const delta1 = scoreTask({
|
||||
user: ref.afterUser, task: habit, direction: 'up', times: 5, cron: false,
|
||||
});
|
||||
|
||||
ref = beforeAfter();
|
||||
habit = generateHabit({ userId: ref.afterUser._id, text: 'some habit' });
|
||||
|
||||
delta2 = scoreTask({ user: ref.afterUser, task: habit, direction: 'up', times: 4, cron: false });
|
||||
const delta2 = scoreTask({
|
||||
user: ref.afterUser, task: habit, direction: 'up', times: 4, cron: false,
|
||||
});
|
||||
|
||||
ref = beforeAfter();
|
||||
habit = generateHabit({ userId: ref.afterUser._id, text: 'some habit' });
|
||||
|
||||
delta3 = scoreTask({ user: ref.afterUser, task: habit, direction: 'up', times: 5, cron: false });
|
||||
const delta3 = scoreTask({
|
||||
user: ref.afterUser, task: habit, direction: 'up', times: 5, cron: false,
|
||||
});
|
||||
|
||||
expect(Math.abs(delta1 - delta2)).to.be.greaterThan(EPSILON);
|
||||
expect(Math.abs(delta1 - delta3)).to.be.lessThan(EPSILON);
|
||||
@@ -108,58 +112,62 @@ describe('shared.ops.scoreTask', () => {
|
||||
});
|
||||
|
||||
it('checks that the streak parameters affects the score', () => {
|
||||
let task = generateDaily({ userId: ref.afterUser._id, text: 'task to check streak' });
|
||||
scoreTask({ user: ref.afterUser, task, direction: 'up', cron: false });
|
||||
scoreTask({ user: ref.afterUser, task, direction: 'up', cron: false });
|
||||
const task = generateDaily({ userId: ref.afterUser._id, text: 'task to check streak' });
|
||||
scoreTask({
|
||||
user: ref.afterUser, task, direction: 'up', cron: false,
|
||||
});
|
||||
scoreTask({
|
||||
user: ref.afterUser, task, direction: 'up', cron: false,
|
||||
});
|
||||
expect(task.streak).to.eql(2);
|
||||
});
|
||||
|
||||
describe('verifies that 21-day streak achievements are given/removed correctly', () => {
|
||||
let initialStreakCount = 20; // 1 before the streak achievement is awarded
|
||||
const initialStreakCount = 20; // 1 before the streak achievement is awarded
|
||||
beforeEach(() => {
|
||||
ref = beforeAfter();
|
||||
});
|
||||
|
||||
it('awards the first streak achievement', () => {
|
||||
let task = generateDaily({ userId: ref.afterUser._id, text: 'some daily', streak: initialStreakCount });
|
||||
const task = generateDaily({ userId: ref.afterUser._id, text: 'some daily', streak: initialStreakCount });
|
||||
scoreTask({ user: ref.afterUser, task, direction: 'up' });
|
||||
expect(ref.afterUser.achievements.streak).to.equal(1);
|
||||
});
|
||||
|
||||
it('increments the streak achievement for a second streak', () => {
|
||||
let task1 = generateDaily({ userId: ref.afterUser._id, text: 'first daily', streak: initialStreakCount });
|
||||
const task1 = generateDaily({ userId: ref.afterUser._id, text: 'first daily', streak: initialStreakCount });
|
||||
scoreTask({ user: ref.afterUser, task: task1, direction: 'up' });
|
||||
let task2 = generateDaily({ userId: ref.afterUser._id, text: 'second daily', streak: initialStreakCount });
|
||||
const task2 = generateDaily({ userId: ref.afterUser._id, text: 'second daily', streak: initialStreakCount });
|
||||
scoreTask({ user: ref.afterUser, task: task2, direction: 'up' });
|
||||
expect(ref.afterUser.achievements.streak).to.equal(2);
|
||||
});
|
||||
|
||||
it('removes the first streak achievement when unticking a Daily', () => {
|
||||
let task = generateDaily({ userId: ref.afterUser._id, text: 'some daily', streak: initialStreakCount });
|
||||
const task = generateDaily({ userId: ref.afterUser._id, text: 'some daily', streak: initialStreakCount });
|
||||
scoreTask({ user: ref.afterUser, task, direction: 'up' });
|
||||
scoreTask({ user: ref.afterUser, task, direction: 'down' });
|
||||
expect(ref.afterUser.achievements.streak).to.equal(0);
|
||||
});
|
||||
|
||||
it('decrements a multiple streak achievement when unticking a Daily', () => {
|
||||
let task1 = generateDaily({ userId: ref.afterUser._id, text: 'first daily', streak: initialStreakCount });
|
||||
const task1 = generateDaily({ userId: ref.afterUser._id, text: 'first daily', streak: initialStreakCount });
|
||||
scoreTask({ user: ref.afterUser, task: task1, direction: 'up' });
|
||||
let task2 = generateDaily({ userId: ref.afterUser._id, text: 'second daily', streak: initialStreakCount });
|
||||
const task2 = generateDaily({ userId: ref.afterUser._id, text: 'second daily', streak: initialStreakCount });
|
||||
scoreTask({ user: ref.afterUser, task: task2, direction: 'up' });
|
||||
scoreTask({ user: ref.afterUser, task: task2, direction: 'down' });
|
||||
expect(ref.afterUser.achievements.streak).to.equal(1);
|
||||
});
|
||||
|
||||
it('does not give a streak achievement for a streak of zero', () => {
|
||||
let task = generateDaily({ userId: ref.afterUser._id, text: 'some daily', streak: -1 });
|
||||
const task = generateDaily({ userId: ref.afterUser._id, text: 'some daily', streak: -1 });
|
||||
scoreTask({ user: ref.afterUser, task, direction: 'up' });
|
||||
expect(ref.afterUser.achievements.streak).to.equal(0);
|
||||
});
|
||||
|
||||
it('does not remove a streak achievement when unticking a Daily gives a streak of zero', () => {
|
||||
let task1 = generateDaily({ userId: ref.afterUser._id, text: 'first daily', streak: initialStreakCount });
|
||||
const task1 = generateDaily({ userId: ref.afterUser._id, text: 'first daily', streak: initialStreakCount });
|
||||
scoreTask({ user: ref.afterUser, task: task1, direction: 'up' });
|
||||
let task2 = generateDaily({ userId: ref.afterUser._id, text: 'second daily', streak: 1 });
|
||||
const task2 = generateDaily({ userId: ref.afterUser._id, text: 'second daily', streak: 1 });
|
||||
scoreTask({ user: ref.afterUser, task: task2, direction: 'down' });
|
||||
expect(ref.afterUser.achievements.streak).to.equal(1);
|
||||
});
|
||||
@@ -168,8 +176,10 @@ describe('shared.ops.scoreTask', () => {
|
||||
describe('scores', () => {
|
||||
let options = {};
|
||||
let habit;
|
||||
let freshDaily, daily;
|
||||
let freshTodo, todo;
|
||||
let freshDaily; let
|
||||
daily;
|
||||
let freshTodo; let
|
||||
todo;
|
||||
|
||||
beforeEach(() => {
|
||||
ref = beforeAfter(options);
|
||||
@@ -190,21 +200,25 @@ describe('shared.ops.scoreTask', () => {
|
||||
});
|
||||
|
||||
it('critical hits', () => {
|
||||
let normalUser = ref.beforeUser;
|
||||
const normalUser = ref.beforeUser;
|
||||
expect(normalUser.party.quest.progress.up).to.eql(0);
|
||||
normalUser.party.quest.key = 'gryphon';
|
||||
let critUser = ref.afterUser;
|
||||
const critUser = ref.afterUser;
|
||||
expect(critUser.party.quest.progress.up).to.eql(0);
|
||||
critUser.party.quest.key = 'gryphon';
|
||||
let normalTask = todo;
|
||||
let critTask = freshTodo;
|
||||
const normalTask = todo;
|
||||
const critTask = freshTodo;
|
||||
|
||||
scoreTask({ user: normalUser, task: normalTask, direction: 'up', cron: false });
|
||||
let normalTaskDelta = normalUser.party.quest.progress.up;
|
||||
scoreTask({
|
||||
user: normalUser, task: normalTask, direction: 'up', cron: false,
|
||||
});
|
||||
const normalTaskDelta = normalUser.party.quest.progress.up;
|
||||
|
||||
sandbox.stub(crit, 'crit').returns(1.5);
|
||||
scoreTask({ user: critUser, task: critTask, direction: 'up', cron: false });
|
||||
let critTaskDelta = critUser.party.quest.progress.up;
|
||||
scoreTask({
|
||||
user: critUser, task: critTask, direction: 'up', cron: false,
|
||||
});
|
||||
const critTaskDelta = critUser.party.quest.progress.up;
|
||||
crit.crit.restore();
|
||||
|
||||
expect(critUser.stats.hp).to.eql(normalUser.stats.hp);
|
||||
@@ -219,20 +233,26 @@ describe('shared.ops.scoreTask', () => {
|
||||
expect(ref.afterUser.party.quest.progress.up).to.eql(0);
|
||||
ref.afterUser.party.quest.key = 'gryphon';
|
||||
|
||||
scoreTask({ user: ref.afterUser, task: habit, direction: 'up', cron: false });
|
||||
let firstTaskDelta = ref.afterUser.party.quest.progress.up;
|
||||
scoreTask({
|
||||
user: ref.afterUser, task: habit, direction: 'up', cron: false,
|
||||
});
|
||||
const firstTaskDelta = ref.afterUser.party.quest.progress.up;
|
||||
expect(firstTaskDelta).to.be.greaterThan(0);
|
||||
expect(ref.afterUser._tmp.quest.progressDelta).to.eql(firstTaskDelta);
|
||||
|
||||
scoreTask({ user: ref.afterUser, task: habit, direction: 'up', cron: false });
|
||||
let secondTaskDelta = ref.afterUser.party.quest.progress.up - firstTaskDelta;
|
||||
scoreTask({
|
||||
user: ref.afterUser, task: habit, direction: 'up', cron: false,
|
||||
});
|
||||
const secondTaskDelta = ref.afterUser.party.quest.progress.up - firstTaskDelta;
|
||||
expect(secondTaskDelta).to.be.greaterThan(0);
|
||||
expect(ref.afterUser._tmp.quest.progressDelta).to.eql(secondTaskDelta);
|
||||
});
|
||||
|
||||
it('does not modify stats when task need approval', () => {
|
||||
todo.group.approval.required = true;
|
||||
options = { user: ref.afterUser, task: todo, direction: 'up', times: 5, cron: false };
|
||||
options = {
|
||||
user: ref.afterUser, task: todo, direction: 'up', times: 5, cron: false,
|
||||
};
|
||||
scoreTask(options);
|
||||
|
||||
expect(ref.afterUser.stats.hp).to.eql(50);
|
||||
@@ -242,7 +262,9 @@ describe('shared.ops.scoreTask', () => {
|
||||
|
||||
context('habits', () => {
|
||||
it('up', () => {
|
||||
options = { user: ref.afterUser, task: habit, direction: 'up', times: 5, cron: false };
|
||||
options = {
|
||||
user: ref.afterUser, task: habit, direction: 'up', times: 5, cron: false,
|
||||
};
|
||||
scoreTask(options);
|
||||
|
||||
expect(habit.history.length).to.eql(1);
|
||||
@@ -256,16 +278,20 @@ describe('shared.ops.scoreTask', () => {
|
||||
|
||||
// not supported anymore
|
||||
it('does not add score notes to task', () => {
|
||||
let scoreNotesString = 'scoreNotes';
|
||||
const scoreNotesString = 'scoreNotes';
|
||||
habit.scoreNotes = scoreNotesString;
|
||||
options = { user: ref.afterUser, task: habit, direction: 'up', times: 5, cron: false };
|
||||
options = {
|
||||
user: ref.afterUser, task: habit, direction: 'up', times: 5, cron: false,
|
||||
};
|
||||
scoreTask(options);
|
||||
|
||||
expect(habit.history[0].scoreNotes).to.eql(undefined);
|
||||
});
|
||||
|
||||
it('down', () => {
|
||||
scoreTask({user: ref.afterUser, task: habit, direction: 'down', times: 5, cron: false}, {});
|
||||
scoreTask({
|
||||
user: ref.afterUser, task: habit, direction: 'down', times: 5, cron: false,
|
||||
}, {});
|
||||
|
||||
expect(habit.history.length).to.eql(1);
|
||||
expect(habit.value).to.be.lessThan(0);
|
||||
@@ -280,16 +306,16 @@ describe('shared.ops.scoreTask', () => {
|
||||
context('dailys', () => {
|
||||
it('up', () => {
|
||||
expect(daily.completed).to.not.eql(true);
|
||||
scoreTask({user: ref.afterUser, task: daily, direction: 'up'});
|
||||
scoreTask({ user: ref.afterUser, task: daily, direction: 'up' });
|
||||
expectGainedPoints(ref.beforeUser, ref.afterUser, freshDaily, daily);
|
||||
expect(daily.completed).to.eql(true);
|
||||
expect(daily.history.length).to.eql(1);
|
||||
});
|
||||
|
||||
it('up, down', () => {
|
||||
scoreTask({user: ref.afterUser, task: daily, direction: 'up'});
|
||||
scoreTask({ user: ref.afterUser, task: daily, direction: 'up' });
|
||||
expect(daily.history.length).to.eql(1);
|
||||
scoreTask({user: ref.afterUser, task: daily, direction: 'down'});
|
||||
scoreTask({ user: ref.afterUser, task: daily, direction: 'down' });
|
||||
expect(daily.history.length).to.eql(0);
|
||||
expectClosePoints(ref.beforeUser, ref.afterUser, freshDaily, daily);
|
||||
});
|
||||
@@ -297,20 +323,20 @@ describe('shared.ops.scoreTask', () => {
|
||||
it('sets completed = false on direction = down', () => {
|
||||
daily.completed = true;
|
||||
expect(daily.completed).to.not.eql(false);
|
||||
scoreTask({user: ref.afterUser, task: daily, direction: 'down'});
|
||||
scoreTask({ user: ref.afterUser, task: daily, direction: 'down' });
|
||||
expect(daily.completed).to.eql(false);
|
||||
});
|
||||
});
|
||||
|
||||
context('todos', () => {
|
||||
it('up', () => {
|
||||
scoreTask({user: ref.afterUser, task: todo, direction: 'up'});
|
||||
scoreTask({ user: ref.afterUser, task: todo, direction: 'up' });
|
||||
expectGainedPoints(ref.beforeUser, ref.afterUser, freshTodo, todo);
|
||||
});
|
||||
|
||||
it('up, down', () => {
|
||||
scoreTask({user: ref.afterUser, task: todo, direction: 'up'});
|
||||
scoreTask({user: ref.afterUser, task: todo, direction: 'down'});
|
||||
scoreTask({ user: ref.afterUser, task: todo, direction: 'up' });
|
||||
scoreTask({ user: ref.afterUser, task: todo, direction: 'down' });
|
||||
expectClosePoints(ref.beforeUser, ref.afterUser, freshTodo, todo);
|
||||
});
|
||||
});
|
||||
|
||||
+24
-24
@@ -12,16 +12,16 @@ import content from '../../../website/common/script/content/index';
|
||||
|
||||
describe('shared.ops.sell', () => {
|
||||
let user;
|
||||
let type = 'eggs';
|
||||
let key = 'Wolf';
|
||||
let acceptedTypes = ['eggs', 'hatchingPotions', 'food'];
|
||||
const type = 'eggs';
|
||||
const key = 'Wolf';
|
||||
const acceptedTypes = ['eggs', 'hatchingPotions', 'food'];
|
||||
|
||||
beforeEach(() => {
|
||||
user = generateUser();
|
||||
user.items[type][key] = 1;
|
||||
});
|
||||
|
||||
it('returns an error when type is not provided', (done) => {
|
||||
it('returns an error when type is not provided', done => {
|
||||
try {
|
||||
sell(user);
|
||||
} catch (err) {
|
||||
@@ -31,9 +31,9 @@ describe('shared.ops.sell', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('returns an error when key is not provided', (done) => {
|
||||
it('returns an error when key is not provided', done => {
|
||||
try {
|
||||
sell(user, {params: { type } });
|
||||
sell(user, { params: { type } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(BadRequest);
|
||||
expect(err.message).to.equal(i18n.t('missingKeyParam'));
|
||||
@@ -41,56 +41,56 @@ describe('shared.ops.sell', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('returns an error when non-sellable type is provided', (done) => {
|
||||
let nonSellableType = 'nonSellableType';
|
||||
it('returns an error when non-sellable type is provided', done => {
|
||||
const nonSellableType = 'nonSellableType';
|
||||
|
||||
try {
|
||||
sell(user, {params: { type: nonSellableType, key } });
|
||||
sell(user, { params: { type: nonSellableType, key } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('typeNotSellable', {acceptedTypes: acceptedTypes.join(', ')}));
|
||||
expect(err.message).to.equal(i18n.t('typeNotSellable', { acceptedTypes: acceptedTypes.join(', ') }));
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('returns an error when key is not found with type provided', (done) => {
|
||||
let fakeKey = 'fakeKey';
|
||||
it('returns an error when key is not found with type provided', done => {
|
||||
const fakeKey = 'fakeKey';
|
||||
|
||||
try {
|
||||
sell(user, {params: { type, key: fakeKey } });
|
||||
sell(user, { params: { type, key: fakeKey } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotFound);
|
||||
expect(err.message).to.equal(i18n.t('userItemsKeyNotFound', {type}));
|
||||
expect(err.message).to.equal(i18n.t('userItemsKeyNotFound', { type }));
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('returns an error when the requested amount is above the available amount', (done) => {
|
||||
it('returns an error when the requested amount is above the available amount', done => {
|
||||
try {
|
||||
sell(user, {params: { type, key }, query: {amount: 2} });
|
||||
sell(user, { params: { type, key }, query: { amount: 2 } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotFound);
|
||||
expect(err.message).to.equal(i18n.t('userItemsNotEnough', {type}));
|
||||
expect(err.message).to.equal(i18n.t('userItemsNotEnough', { type }));
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('returns an error when the requested amount is negative', (done) => {
|
||||
it('returns an error when the requested amount is negative', done => {
|
||||
try {
|
||||
sell(user, {params: { type, key }, query: {amount: -42} });
|
||||
sell(user, { params: { type, key }, query: { amount: -42 } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(BadRequest);
|
||||
expect(err.message).to.equal(i18n.t('positiveAmountRequired', {type}));
|
||||
expect(err.message).to.equal(i18n.t('positiveAmountRequired', { type }));
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('returns error when trying to sell Saddle', (done) => {
|
||||
it('returns error when trying to sell Saddle', done => {
|
||||
const foodType = 'food';
|
||||
const saddleKey = 'Saddle';
|
||||
user.items[foodType][saddleKey] = 1;
|
||||
try {
|
||||
sell(user, {params: {type: foodType, key: saddleKey}});
|
||||
sell(user, { params: { type: foodType, key: saddleKey } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('foodSaddleSellWarningNote'));
|
||||
@@ -99,13 +99,13 @@ describe('shared.ops.sell', () => {
|
||||
});
|
||||
|
||||
it('reduces item count from user', () => {
|
||||
sell(user, {params: { type, key } });
|
||||
sell(user, { params: { type, key } });
|
||||
|
||||
expect(user.items[type][key]).to.equal(0);
|
||||
});
|
||||
|
||||
it('increases user\'s gold', () => {
|
||||
sell(user, {params: { type, key } });
|
||||
sell(user, { params: { type, key } });
|
||||
|
||||
expect(user.stats.gp).to.equal(content[type][key].value);
|
||||
});
|
||||
|
||||
@@ -5,13 +5,13 @@ import {
|
||||
|
||||
describe('shared.ops.sleep', () => {
|
||||
it('toggles user.preferences.sleep', () => {
|
||||
let user = generateUser();
|
||||
const user = generateUser();
|
||||
|
||||
let [res] = sleep(user);
|
||||
const [res] = sleep(user);
|
||||
expect(res).to.eql(true);
|
||||
expect(user.preferences.sleep).to.equal(true);
|
||||
|
||||
let [res2] = sleep(user);
|
||||
const [res2] = sleep(user);
|
||||
expect(res2).to.eql(false);
|
||||
expect(user.preferences.sleep).to.equal(false);
|
||||
});
|
||||
|
||||
@@ -16,13 +16,13 @@ describe('shared.ops.spells', () => {
|
||||
user = generateUser();
|
||||
});
|
||||
|
||||
it('returns an error when healer tries to cast Healing Light with full health', (done) => {
|
||||
it('returns an error when healer tries to cast Healing Light with full health', done => {
|
||||
user.stats.class = 'healer';
|
||||
user.stats.lvl = 11;
|
||||
user.stats.hp = 50;
|
||||
user.stats.mp = 200;
|
||||
|
||||
let spell = spells.healer.heal;
|
||||
const spell = spells.healer.heal;
|
||||
|
||||
try {
|
||||
spell.cast(user);
|
||||
@@ -35,4 +35,4 @@ describe('shared.ops.spells', () => {
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -20,19 +20,19 @@ describe('shared.ops.allocate', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('throws an error if an invalid attribute is supplied', (done) => {
|
||||
it('throws an error if an invalid attribute is supplied', done => {
|
||||
try {
|
||||
allocate(user, {
|
||||
query: {stat: 'notValid'},
|
||||
query: { stat: 'notValid' },
|
||||
});
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(BadRequest);
|
||||
expect(err.message).to.equal(errorMessage('invalidAttribute', {attr: 'notValid'}));
|
||||
expect(err.message).to.equal(errorMessage('invalidAttribute', { attr: 'notValid' }));
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('throws an error if the user is below lvl 10', (done) => {
|
||||
it('throws an error if the user is below lvl 10', done => {
|
||||
user.stats.lvl = 9;
|
||||
try {
|
||||
allocate(user);
|
||||
@@ -43,7 +43,7 @@ describe('shared.ops.allocate', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('throws an error if the user hasn\'t selected class', (done) => {
|
||||
it('throws an error if the user hasn\'t selected class', done => {
|
||||
user.flags.classSelected = false;
|
||||
try {
|
||||
allocate(user);
|
||||
@@ -54,7 +54,7 @@ describe('shared.ops.allocate', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('throws an error if the user has disabled classes', (done) => {
|
||||
it('throws an error if the user has disabled classes', done => {
|
||||
user.preferences.disableClasses = true;
|
||||
try {
|
||||
allocate(user);
|
||||
@@ -65,7 +65,7 @@ describe('shared.ops.allocate', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('throws an error if the user doesn\'t have attribute points', (done) => {
|
||||
it('throws an error if the user doesn\'t have attribute points', done => {
|
||||
try {
|
||||
allocate(user);
|
||||
} catch (err) {
|
||||
@@ -85,7 +85,7 @@ describe('shared.ops.allocate', () => {
|
||||
it('allocates attribute points', () => {
|
||||
expect(user.stats.con).to.equal(0);
|
||||
user.stats.points = 1;
|
||||
allocate(user, {query: {stat: 'con'}});
|
||||
allocate(user, { query: { stat: 'con' } });
|
||||
expect(user.stats.con).to.equal(1);
|
||||
expect(user.stats.points).to.equal(0);
|
||||
});
|
||||
@@ -94,7 +94,7 @@ describe('shared.ops.allocate', () => {
|
||||
expect(user.stats.int).to.equal(0);
|
||||
expect(user.stats.mp).to.equal(10);
|
||||
user.stats.points = 1;
|
||||
allocate(user, {query: {stat: 'int'}});
|
||||
allocate(user, { query: { stat: 'int' } });
|
||||
expect(user.stats.int).to.equal(1);
|
||||
expect(user.stats.mp).to.equal(11);
|
||||
});
|
||||
|
||||
@@ -20,7 +20,7 @@ describe('shared.ops.allocateBulk', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('throws an error if an invalid attribute is supplied', (done) => {
|
||||
it('throws an error if an invalid attribute is supplied', done => {
|
||||
try {
|
||||
allocateBulk(user, {
|
||||
body: {
|
||||
@@ -32,12 +32,12 @@ describe('shared.ops.allocateBulk', () => {
|
||||
});
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(BadRequest);
|
||||
expect(err.message).to.equal(errorMessage('invalidAttribute', {attr: 'invalid'}));
|
||||
expect(err.message).to.equal(errorMessage('invalidAttribute', { attr: 'invalid' }));
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('throws an error if the stats are not supplied', (done) => {
|
||||
it('throws an error if the stats are not supplied', done => {
|
||||
try {
|
||||
allocateBulk(user);
|
||||
} catch (err) {
|
||||
@@ -47,7 +47,7 @@ describe('shared.ops.allocateBulk', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('throws an error if the user is below lvl 10', (done) => {
|
||||
it('throws an error if the user is below lvl 10', done => {
|
||||
user.stats.lvl = 9;
|
||||
try {
|
||||
allocateBulk(user, {
|
||||
@@ -65,7 +65,7 @@ describe('shared.ops.allocateBulk', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('throws an error if the user hasn\'t selected class', (done) => {
|
||||
it('throws an error if the user hasn\'t selected class', done => {
|
||||
user.flags.classSelected = false;
|
||||
try {
|
||||
allocateBulk(user, {
|
||||
@@ -83,7 +83,7 @@ describe('shared.ops.allocateBulk', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('throws an error if the user has disabled classes', (done) => {
|
||||
it('throws an error if the user has disabled classes', done => {
|
||||
user.preferences.disableClasses = true;
|
||||
try {
|
||||
allocateBulk(user, {
|
||||
@@ -101,7 +101,7 @@ describe('shared.ops.allocateBulk', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('throws an error if the user doesn\'t have attribute points', (done) => {
|
||||
it('throws an error if the user doesn\'t have attribute points', done => {
|
||||
try {
|
||||
allocateBulk(user, {
|
||||
body: {
|
||||
@@ -118,7 +118,7 @@ describe('shared.ops.allocateBulk', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('throws an error if the user doesn\'t have enough attribute points', (done) => {
|
||||
it('throws an error if the user doesn\'t have enough attribute points', done => {
|
||||
user.stats.points = 1;
|
||||
try {
|
||||
allocateBulk(user, {
|
||||
|
||||
@@ -18,7 +18,7 @@ describe('shared.ops.allocateNow', () => {
|
||||
user.stats.str = 9;
|
||||
user.preferences.allocationMode = 'flat';
|
||||
|
||||
let [data] = allocateNow(user);
|
||||
const [data] = allocateNow(user);
|
||||
|
||||
expect(user.stats.points).to.equal(0);
|
||||
expect(user.stats.con).to.equal(9);
|
||||
|
||||
+25
-25
@@ -10,18 +10,18 @@ import {
|
||||
|
||||
describe('shared.ops.unlock', () => {
|
||||
let user;
|
||||
let unlockPath = 'shirt.convict,shirt.cross,shirt.fire,shirt.horizon,shirt.ocean,shirt.purple,shirt.rainbow,shirt.redblue,shirt.thunder,shirt.tropical,shirt.zombie';
|
||||
let unlockGearSetPath = 'items.gear.owned.headAccessory_special_bearEars,items.gear.owned.headAccessory_special_cactusEars,items.gear.owned.headAccessory_special_foxEars,items.gear.owned.headAccessory_special_lionEars,items.gear.owned.headAccessory_special_pandaEars,items.gear.owned.headAccessory_special_pigEars,items.gear.owned.headAccessory_special_tigerEars,items.gear.owned.headAccessory_special_wolfEars';
|
||||
let backgroundUnlockPath = 'background.giant_florals';
|
||||
let unlockCost = 1.25;
|
||||
let usersStartingGems = 5;
|
||||
const unlockPath = 'shirt.convict,shirt.cross,shirt.fire,shirt.horizon,shirt.ocean,shirt.purple,shirt.rainbow,shirt.redblue,shirt.thunder,shirt.tropical,shirt.zombie';
|
||||
const unlockGearSetPath = 'items.gear.owned.headAccessory_special_bearEars,items.gear.owned.headAccessory_special_cactusEars,items.gear.owned.headAccessory_special_foxEars,items.gear.owned.headAccessory_special_lionEars,items.gear.owned.headAccessory_special_pandaEars,items.gear.owned.headAccessory_special_pigEars,items.gear.owned.headAccessory_special_tigerEars,items.gear.owned.headAccessory_special_wolfEars';
|
||||
const backgroundUnlockPath = 'background.giant_florals';
|
||||
const unlockCost = 1.25;
|
||||
const usersStartingGems = 5;
|
||||
|
||||
beforeEach(() => {
|
||||
user = generateUser();
|
||||
user.balance = usersStartingGems;
|
||||
});
|
||||
|
||||
it('returns an error when path is not provided', (done) => {
|
||||
it('returns an error when path is not provided', done => {
|
||||
try {
|
||||
unlock(user);
|
||||
} catch (err) {
|
||||
@@ -31,11 +31,11 @@ describe('shared.ops.unlock', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('returns an error when user balance is too low', (done) => {
|
||||
it('returns an error when user balance is too low', done => {
|
||||
user.balance = 0;
|
||||
|
||||
try {
|
||||
unlock(user, {query: {path: unlockPath}});
|
||||
unlock(user, { query: { path: unlockPath } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('notEnoughGems'));
|
||||
@@ -43,10 +43,10 @@ describe('shared.ops.unlock', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('returns an error when user already owns a full set', (done) => {
|
||||
it('returns an error when user already owns a full set', done => {
|
||||
try {
|
||||
unlock(user, {query: {path: unlockPath}});
|
||||
unlock(user, {query: {path: unlockPath}});
|
||||
unlock(user, { query: { path: unlockPath } });
|
||||
unlock(user, { query: { path: unlockPath } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('alreadyUnlocked'));
|
||||
@@ -55,10 +55,10 @@ describe('shared.ops.unlock', () => {
|
||||
});
|
||||
|
||||
// disabled untill fully implemente
|
||||
xit('returns an error when user already owns items in a full set', (done) => {
|
||||
xit('returns an error when user already owns items in a full set', done => {
|
||||
try {
|
||||
unlock(user, {query: {path: unlockPath}});
|
||||
unlock(user, {query: {path: unlockPath}});
|
||||
unlock(user, { query: { path: unlockPath } });
|
||||
unlock(user, { query: { path: unlockPath } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('alreadyUnlocked'));
|
||||
@@ -69,9 +69,9 @@ describe('shared.ops.unlock', () => {
|
||||
it('equips an item already owned', () => {
|
||||
expect(user.purchased.background.giant_florals).to.not.exist;
|
||||
|
||||
unlock(user, {query: {path: backgroundUnlockPath}});
|
||||
let afterBalance = user.balance;
|
||||
let response = unlock(user, {query: {path: backgroundUnlockPath}});
|
||||
unlock(user, { query: { path: backgroundUnlockPath } });
|
||||
const afterBalance = user.balance;
|
||||
const response = unlock(user, { query: { path: backgroundUnlockPath } });
|
||||
expect(user.balance).to.equal(afterBalance); // do not bill twice
|
||||
|
||||
expect(response.message).to.not.exist;
|
||||
@@ -81,10 +81,10 @@ describe('shared.ops.unlock', () => {
|
||||
it('un-equips an item already equipped', () => {
|
||||
expect(user.purchased.background.giant_florals).to.not.exist;
|
||||
|
||||
unlock(user, {query: {path: backgroundUnlockPath}}); // unlock
|
||||
let afterBalance = user.balance;
|
||||
unlock(user, {query: {path: backgroundUnlockPath}}); // equip
|
||||
let response = unlock(user, {query: {path: backgroundUnlockPath}});
|
||||
unlock(user, { query: { path: backgroundUnlockPath } }); // unlock
|
||||
const afterBalance = user.balance;
|
||||
unlock(user, { query: { path: backgroundUnlockPath } }); // equip
|
||||
const response = unlock(user, { query: { path: backgroundUnlockPath } });
|
||||
expect(user.balance).to.equal(afterBalance); // do not bill twice
|
||||
|
||||
expect(response.message).to.not.exist;
|
||||
@@ -92,28 +92,28 @@ describe('shared.ops.unlock', () => {
|
||||
});
|
||||
|
||||
it('unlocks a full set', () => {
|
||||
let [, message] = unlock(user, {query: {path: unlockPath}});
|
||||
const [, message] = unlock(user, { query: { path: unlockPath } });
|
||||
|
||||
expect(message).to.equal(i18n.t('unlocked'));
|
||||
expect(user.purchased.shirt.convict).to.be.true;
|
||||
});
|
||||
|
||||
it('unlocks a full set of gear', () => {
|
||||
let [, message] = unlock(user, {query: {path: unlockGearSetPath}});
|
||||
const [, message] = unlock(user, { query: { path: unlockGearSetPath } });
|
||||
|
||||
expect(message).to.equal(i18n.t('unlocked'));
|
||||
expect(user.items.gear.owned.headAccessory_special_wolfEars).to.be.true;
|
||||
});
|
||||
|
||||
it('unlocks a an item', () => {
|
||||
let [, message] = unlock(user, {query: {path: backgroundUnlockPath}});
|
||||
const [, message] = unlock(user, { query: { path: backgroundUnlockPath } });
|
||||
|
||||
expect(message).to.equal(i18n.t('unlocked'));
|
||||
expect(user.purchased.background.giant_florals).to.be.true;
|
||||
});
|
||||
|
||||
it('reduces a user\'s balance', () => {
|
||||
let [, message] = unlock(user, {query: {path: unlockPath}});
|
||||
const [, message] = unlock(user, { query: { path: unlockPath } });
|
||||
|
||||
expect(message).to.equal(i18n.t('unlocked'));
|
||||
expect(user.balance).to.equal(usersStartingGems - unlockCost);
|
||||
|
||||
@@ -5,8 +5,8 @@ import {
|
||||
|
||||
describe('shared.ops.updateTask', () => {
|
||||
it('updates a task', () => {
|
||||
let now = new Date();
|
||||
let habit = generateHabit({
|
||||
const now = new Date();
|
||||
const habit = generateHabit({
|
||||
tags: [
|
||||
'123',
|
||||
'456',
|
||||
@@ -19,7 +19,7 @@ describe('shared.ops.updateTask', () => {
|
||||
}],
|
||||
});
|
||||
|
||||
let [res] = updateTask(habit, {
|
||||
const [res] = updateTask(habit, {
|
||||
body: {
|
||||
text: 'updated',
|
||||
id: '123',
|
||||
|
||||
Reference in New Issue
Block a user