mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-05-19 20:28:53 +00:00
Re-enable armoire tests
This commit is contained in:
parent
d2756278c3
commit
f9595af8a5
3 changed files with 13 additions and 10 deletions
|
|
@ -5,6 +5,7 @@ import {
|
|||
} from '../../helpers/common.helper';
|
||||
import count from '../../../website/common/script/count';
|
||||
import buyArmoire from '../../../website/common/script/ops/buyArmoire';
|
||||
import randomVal from '../../../website/common/script/libs/randomVal';
|
||||
import content from '../../../website/common/script/content/index';
|
||||
import {
|
||||
NotAuthorized,
|
||||
|
|
@ -25,7 +26,7 @@ function getFullArmoire () {
|
|||
return fullArmoire;
|
||||
}
|
||||
|
||||
xdescribe('shared.ops.buyArmoire', () => {
|
||||
describe('shared.ops.buyArmoire', () => {
|
||||
let user;
|
||||
let YIELD_EQUIPMENT = 0.5;
|
||||
let YIELD_FOOD = 0.7;
|
||||
|
|
@ -43,11 +44,11 @@ xdescribe('shared.ops.buyArmoire', () => {
|
|||
user.stats.exp = 0;
|
||||
user.items.food = {};
|
||||
|
||||
sandbox.stub(Math, 'random');
|
||||
sandbox.stub(randomVal, 'trueRandom');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
Math.random.restore();
|
||||
randomVal.trueRandom.restore();
|
||||
});
|
||||
|
||||
context('failure conditions', () => {
|
||||
|
|
@ -89,7 +90,7 @@ xdescribe('shared.ops.buyArmoire', () => {
|
|||
context('non-gear awards', () => {
|
||||
it('gives Experience', () => {
|
||||
let previousExp = user.stats.exp;
|
||||
Math.random.returns(YIELD_EXP);
|
||||
randomVal.trueRandom.returns(YIELD_EXP);
|
||||
|
||||
buyArmoire(user);
|
||||
|
||||
|
|
@ -102,7 +103,7 @@ xdescribe('shared.ops.buyArmoire', () => {
|
|||
it('gives food', () => {
|
||||
let previousExp = user.stats.exp;
|
||||
|
||||
Math.random.returns(YIELD_FOOD);
|
||||
randomVal.trueRandom.returns(YIELD_FOOD);
|
||||
|
||||
buyArmoire(user);
|
||||
|
||||
|
|
@ -113,7 +114,7 @@ xdescribe('shared.ops.buyArmoire', () => {
|
|||
});
|
||||
|
||||
it('does not give equipment if all equipment has been found', () => {
|
||||
Math.random.returns(YIELD_EQUIPMENT);
|
||||
randomVal.trueRandom.returns(YIELD_EQUIPMENT);
|
||||
user.items.gear.owned = getFullArmoire();
|
||||
user.stats.gp = 150;
|
||||
|
||||
|
|
@ -131,7 +132,7 @@ xdescribe('shared.ops.buyArmoire', () => {
|
|||
context('gear awards', () => {
|
||||
it('always drops equipment the first time', () => {
|
||||
delete user.flags.armoireOpened;
|
||||
Math.random.returns(YIELD_EXP);
|
||||
randomVal.trueRandom.returns(YIELD_EXP);
|
||||
|
||||
expect(_.size(user.items.gear.owned)).to.equal(1);
|
||||
|
||||
|
|
@ -148,7 +149,7 @@ xdescribe('shared.ops.buyArmoire', () => {
|
|||
});
|
||||
|
||||
it('gives more equipment', () => {
|
||||
Math.random.returns(YIELD_EQUIPMENT);
|
||||
randomVal.trueRandom.returns(YIELD_EQUIPMENT);
|
||||
user.items.gear.owned = {
|
||||
weapon_warrior_0: true,
|
||||
head_armoire_hornedIronHelm: true,
|
||||
|
|
|
|||
|
|
@ -16,3 +16,5 @@ module.exports = function randomVal (obj, options = {}) {
|
|||
|
||||
return array[randomIndex];
|
||||
};
|
||||
|
||||
module.exports.trueRandom = trueRandom;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ module.exports = function buyArmoire (user, req = {}, analytics) {
|
|||
let drop;
|
||||
let message;
|
||||
|
||||
let armoireResult = Math.random();
|
||||
let armoireResult = randomVal.trueRandom();
|
||||
let eligibleEquipment = _.filter(content.gear.flat, (eligible) => {
|
||||
return eligible.klass === 'armoire' && !user.items.gear.owned[eligible.key];
|
||||
});
|
||||
|
|
@ -79,7 +79,7 @@ module.exports = function buyArmoire (user, req = {}, analytics) {
|
|||
dropText: drop.text(req.language),
|
||||
};
|
||||
} else {
|
||||
let armoireExp = Math.floor(Math.random() * 40 + 10);
|
||||
let armoireExp = Math.floor(randomVal.trueRandom() * 40 + 10);
|
||||
user.stats.exp += armoireExp;
|
||||
message = i18n.t('armoireExp', req.language);
|
||||
armoireResp = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue