fix common tests

This commit is contained in:
Matteo Pagliazzi
2019-10-03 16:27:44 +02:00
parent 5b406ba70f
commit 17c7a2bad1
12 changed files with 989 additions and 837 deletions

1066
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -35,10 +35,10 @@
"image-size": "^0.8.0", "image-size": "^0.8.0",
"in-app-purchase": "^1.11.3", "in-app-purchase": "^1.11.3",
"js2xmlparser": "^4.0.0", "js2xmlparser": "^4.0.0",
"lodash": "^4.17.10", "lodash": "^4.17.15",
"merge-stream": "^2.0.0", "merge-stream": "^2.0.0",
"method-override": "^3.0.0", "method-override": "^3.0.0",
"moment": "^2.22.1", "moment": "^2.24.0",
"moment-recur": "^1.0.7", "moment-recur": "^1.0.7",
"mongoose": "^5.6.9", "mongoose": "^5.6.9",
"morgan": "^1.7.0", "morgan": "^1.7.0",
@@ -59,12 +59,9 @@
"superagent": "^5.0.2", "superagent": "^5.0.2",
"universal-analytics": "^0.4.17", "universal-analytics": "^0.4.17",
"useragent": "^2.1.9", "useragent": "^2.1.9",
"uuid": "^3.0.1", "uuid": "^3.3.3",
"validator": "^11.0.0", "validator": "^11.0.0",
"vinyl-buffer": "^1.0.1", "vinyl-buffer": "^1.0.1",
"vue": "^2.6.10",
"vue-router": "^3.0.0",
"vue-template-compiler": "^2.6.10",
"winston": "^2.4.3", "winston": "^2.4.3",
"winston-loggly-bulk": "^2.0.2", "winston-loggly-bulk": "^2.0.2",
"xml2js": "^0.4.4" "xml2js": "^0.4.4"

View File

@@ -1,4 +1,4 @@
import armoireSet from '../../../website/common/script/content/gear/sets/armoire'; import * as armoireSet from '../../../website/common/script/content/gear/sets/armoire';
describe('armoireSet items', () => { describe('armoireSet items', () => {
it('checks if canOwn has the same id', () => { it('checks if canOwn has the same id', () => {

View File

@@ -3,9 +3,9 @@
import { import {
generateUser, generateUser,
} from '../../../helpers/common.helper'; } from '../../../helpers/common.helper';
import count from '../../../../website/common/script/count'; 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 randomVal from '../../../../website/common/script/libs/randomVal'; import * as randomValFns from '../../../../website/common/script/libs/randomVal';
import content from '../../../../website/common/script/content/index'; import content from '../../../../website/common/script/content/index';
import { import {
NotAuthorized, NotAuthorized,
@@ -51,12 +51,12 @@ describe('shared.ops.buyArmoire', () => {
user.stats.exp = 0; user.stats.exp = 0;
user.items.food = {}; user.items.food = {};
sandbox.stub(randomVal, 'trueRandom'); sandbox.stub(randomValFns, 'trueRandom');
sinon.stub(analytics, 'track'); sinon.stub(analytics, 'track');
}); });
afterEach(() => { afterEach(() => {
randomVal.trueRandom.restore(); randomValFns.trueRandom.restore();
analytics.track.restore(); analytics.track.restore();
}); });
@@ -82,7 +82,7 @@ describe('shared.ops.buyArmoire', () => {
context('non-gear awards', () => { context('non-gear awards', () => {
it('gives Experience', () => { it('gives Experience', () => {
let previousExp = user.stats.exp; let previousExp = user.stats.exp;
randomVal.trueRandom.returns(YIELD_EXP); randomValFns.trueRandom.returns(YIELD_EXP);
buyArmoire(user); buyArmoire(user);
@@ -95,7 +95,7 @@ describe('shared.ops.buyArmoire', () => {
it('gives food', () => { it('gives food', () => {
let previousExp = user.stats.exp; let previousExp = user.stats.exp;
randomVal.trueRandom.returns(YIELD_FOOD); randomValFns.trueRandom.returns(YIELD_FOOD);
buyArmoire(user); buyArmoire(user);
@@ -106,7 +106,7 @@ describe('shared.ops.buyArmoire', () => {
}); });
it('does not give equipment if all equipment has been found', () => { it('does not give equipment if all equipment has been found', () => {
randomVal.trueRandom.returns(YIELD_EQUIPMENT); randomValFns.trueRandom.returns(YIELD_EQUIPMENT);
user.items.gear.owned = getFullArmoire(); user.items.gear.owned = getFullArmoire();
user.stats.gp = 150; user.stats.gp = 150;
@@ -124,7 +124,7 @@ describe('shared.ops.buyArmoire', () => {
context('gear awards', () => { context('gear awards', () => {
it('always drops equipment the first time', () => { it('always drops equipment the first time', () => {
delete user.flags.armoireOpened; delete user.flags.armoireOpened;
randomVal.trueRandom.returns(YIELD_EXP); randomValFns.trueRandom.returns(YIELD_EXP);
expect(_.size(user.items.gear.owned)).to.equal(1); expect(_.size(user.items.gear.owned)).to.equal(1);
@@ -141,7 +141,7 @@ describe('shared.ops.buyArmoire', () => {
}); });
it('gives more equipment', () => { it('gives more equipment', () => {
randomVal.trueRandom.returns(YIELD_EQUIPMENT); randomValFns.trueRandom.returns(YIELD_EQUIPMENT);
user.items.gear.owned = { user.items.gear.owned = {
weapon_warrior_0: true, weapon_warrior_0: true,
head_armoire_hornedIronHelm: true, head_armoire_hornedIronHelm: true,

View File

@@ -1,4 +1,4 @@
import pinnedGearUtils from '../../../../website/common/script/ops/pinnedGearUtils'; import * as pinnedGearUtils from '../../../../website/common/script/ops/pinnedGearUtils';
import { import {
NotAuthorized, NotAuthorized,
} from '../../../../website/common/script/libs/errors'; } from '../../../../website/common/script/libs/errors';

View File

@@ -1,5 +1,5 @@
import purchase from '../../../../website/common/script/ops/buy/purchase'; import purchase from '../../../../website/common/script/ops/buy/purchase';
import pinnedGearUtils from '../../../../website/common/script/ops/pinnedGearUtils'; import * as pinnedGearUtils from '../../../../website/common/script/ops/pinnedGearUtils';
import { import {
BadRequest, BadRequest,
NotAuthorized, NotAuthorized,

View File

@@ -1,10 +1,12 @@
import { import api from '../../website/common/script/index';
const {
maxHealth, maxHealth,
maxLevel, maxLevel,
capByLevel, capByLevel,
tnl, tnl,
diminishingReturns, diminishingReturns,
} from '../../website/common/script/index'; } = api;
describe('helper functions used in stat calculations', () => { describe('helper functions used in stat calculations', () => {
describe('maxHealth', () => { describe('maxHealth', () => {

File diff suppressed because it is too large Load Diff

View File

@@ -19,16 +19,20 @@
"hellojs": "^1.18.1", "hellojs": "^1.18.1",
"intro.js": "^2.9.3", "intro.js": "^2.9.3",
"jquery": "^3.4.1", "jquery": "^3.4.1",
"lodash": "^4.17.15",
"moment": "^2.24.0",
"smartbanner.js": "^1.14.5", "smartbanner.js": "^1.14.5",
"svg-inline-loader": "^0.8.0", "svg-inline-loader": "^0.8.0",
"svg-url-loader": "^3.0.2", "svg-url-loader": "^3.0.2",
"svgo": "^1.3.0", "svgo": "^1.3.0",
"svgo-loader": "^2.2.1", "svgo-loader": "^2.2.1",
"uuid": "^3.3.3",
"validator": "^11.1.0",
"vue": "^2.6.10", "vue": "^2.6.10",
"vue-mugen-scroll": "^0.2.6", "vue-mugen-scroll": "^0.2.6",
"vue-router": "^3.0.6", "vue-router": "^3.0.6",
"vuedraggable": "^2.23.1", "vuedraggable": "^2.23.1",
"vuejs-datepicker": "^1.6.2" "vuejs-datepicker": "git://github.com/habitrpg/vuejs-datepicker.git#5d237615463a84a23dd6f3f77c6ab577d68593ec"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-babel": "^4.0.0-rc.6", "@vue/cli-plugin-babel": "^4.0.0-rc.6",
@@ -41,6 +45,7 @@
"chai": "^4.1.2", "chai": "^4.1.2",
"eslint": "^5.16.0", "eslint": "^5.16.0",
"eslint-plugin-vue": "^5.0.0", "eslint-plugin-vue": "^5.0.0",
"inspectpack": "^4.2.2",
"pug": "^2.0.4", "pug": "^2.0.4",
"pug-plain-loader": "^1.0.0", "pug-plain-loader": "^1.0.0",
"sass": "^1.19.0", "sass": "^1.19.0",

View File

@@ -87,7 +87,7 @@ const QuestsPage = () => import(/* webpackChunkName: "shops-quest" */'@/componen
const SeasonalPage = () => import(/* webpackChunkName: "shops-seasonal" */'@/components/shops/seasonal/index'); const SeasonalPage = () => import(/* webpackChunkName: "shops-seasonal" */'@/components/shops/seasonal/index');
const TimeTravelersPage = () => import(/* webpackChunkName: "shops-timetravelers" */'@/components/shops/timeTravelers/index'); const TimeTravelersPage = () => import(/* webpackChunkName: "shops-timetravelers" */'@/components/shops/timeTravelers/index');
import NotFoundPage from '@/components/404'; const NotFoundPage = () => import(/* webpackChunkName: "not-found" */'@/components/404');
Vue.use(VueRouter); Vue.use(VueRouter);

View File

@@ -2,6 +2,7 @@ const path = require('path');
const webpack = require('webpack'); const webpack = require('webpack');
const nconf = require('nconf'); const nconf = require('nconf');
const setupNconf = require('../../website/server/libs/setupNconf'); const setupNconf = require('../../website/server/libs/setupNconf');
const { DuplicatesPlugin } = require("inspectpack/plugin");
let configFile = path.join(path.resolve(__dirname, '../../config.json')); let configFile = path.join(path.resolve(__dirname, '../../config.json'));
@@ -37,6 +38,9 @@ envVars
module.exports = { module.exports = {
configureWebpack: { configureWebpack: {
plugins: [ plugins: [
new DuplicatesPlugin({
verbose: true
}),
new webpack.EnvironmentPlugin(envObject), new webpack.EnvironmentPlugin(envObject),
new webpack.ContextReplacementPlugin(/moment[\\/]locale$/, /^\.\/(NOT_EXISTING)$/), new webpack.ContextReplacementPlugin(/moment[\\/]locale$/, /^\.\/(NOT_EXISTING)$/),
], ],

View File

@@ -7,7 +7,7 @@ import splitWhitespace from '../../libs/splitWhitespace';
import { import {
NotAuthorized, NotAuthorized,
} from '../../libs/errors'; } from '../../libs/errors';
import randomVal from '../../libs/randomVal'; import randomVal, * as randomValFns from '../../libs/randomVal';
import {removeItemByPath} from '../pinnedGearUtils'; import {removeItemByPath} from '../pinnedGearUtils';
import {AbstractGoldItemOperation} from './abstractBuyOperation'; import {AbstractGoldItemOperation} from './abstractBuyOperation';
@@ -35,7 +35,7 @@ export class BuyArmoireOperation extends AbstractGoldItemOperation {
executeChanges (user, item) { executeChanges (user, item) {
let result = {}; let result = {};
let armoireResult = randomVal.trueRandom(); let armoireResult = randomValFns.trueRandom();
let eligibleEquipment = filter(content.gear.flat, (eligible) => { let eligibleEquipment = filter(content.gear.flat, (eligible) => {
return eligible.klass === 'armoire' && !user.items.gear.owned[eligible.key]; return eligible.klass === 'armoire' && !user.items.gear.owned[eligible.key];
}); });
@@ -147,7 +147,7 @@ export class BuyArmoireOperation extends AbstractGoldItemOperation {
} }
_experienceResult (user) { _experienceResult (user) {
let armoireExp = Math.floor(randomVal.trueRandom() * 40 + 10); let armoireExp = Math.floor(randomValFns.trueRandom() * 40 + 10);
user.stats.exp += armoireExp; user.stats.exp += armoireExp;
return { return {