mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-04-14 11:46:23 +00:00
fix tests
This commit is contained in:
parent
fc63c906dd
commit
fec68e6211
3 changed files with 19 additions and 17 deletions
|
|
@ -117,7 +117,7 @@ describe('Items Utils', () => {
|
||||||
it('converts values for owned gear to true/false', () => {
|
it('converts values for owned gear to true/false', () => {
|
||||||
expect(castItemVal('items.gear.owned.shield_warrior_0', 'true')).to.equal(true);
|
expect(castItemVal('items.gear.owned.shield_warrior_0', 'true')).to.equal(true);
|
||||||
expect(castItemVal('items.gear.owned.invalid', 'false')).to.equal(false);
|
expect(castItemVal('items.gear.owned.invalid', 'false')).to.equal(false);
|
||||||
expect(castItemVal('items.gear.owned.invalid', 'null')).to.equal(false);
|
expect(castItemVal('items.gear.owned.invalid', 'null')).to.equal(undefined);
|
||||||
expect(castItemVal('items.gear.owned.invalid', 'truthy')).to.equal(true);
|
expect(castItemVal('items.gear.owned.invalid', 'truthy')).to.equal(true);
|
||||||
expect(castItemVal('items.gear.owned.invalid', 0)).to.equal(false);
|
expect(castItemVal('items.gear.owned.invalid', 0)).to.equal(false);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -9,18 +9,19 @@ import ensureDevelopmentMode from '../../../../website/server/middlewares/ensure
|
||||||
import { NotFound } from '../../../../website/server/libs/errors';
|
import { NotFound } from '../../../../website/server/libs/errors';
|
||||||
|
|
||||||
describe('developmentMode middleware', () => {
|
describe('developmentMode middleware', () => {
|
||||||
let res; let req; let
|
let res; let req; let next;
|
||||||
next;
|
let nconfStub;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
res = generateRes();
|
res = generateRes();
|
||||||
req = generateReq();
|
req = generateReq();
|
||||||
next = generateNext();
|
next = generateNext();
|
||||||
|
nconfStub = sandbox.stub(nconf, 'get');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns not found when on production URL', () => {
|
it('returns not found when on production URL', () => {
|
||||||
sandbox.stub(nconf, 'get').withArgs('DEBUG_ENABLED').returns(true);
|
nconfStub.withArgs('DEBUG_ENABLED').returns(true);
|
||||||
sandbox.stub(nconf, 'get').withArgs('BASE_URL').returns('https://habitica.com');
|
nconfStub.withArgs('BASE_URL').returns('https://habitica.com');
|
||||||
|
|
||||||
ensureDevelopmentMode(req, res, next);
|
ensureDevelopmentMode(req, res, next);
|
||||||
|
|
||||||
|
|
@ -29,8 +30,8 @@ describe('developmentMode middleware', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns not found when intentionally disabled', () => {
|
it('returns not found when intentionally disabled', () => {
|
||||||
sandbox.stub(nconf, 'get').withArgs('DEBUG_ENABLED').returns(false);
|
nconfStub.withArgs('DEBUG_ENABLED').returns(false);
|
||||||
sandbox.stub(nconf, 'get').withArgs('BASE_URL').returns('http://localhost:3000');
|
nconfStub.withArgs('BASE_URL').returns('http://localhost:3000');
|
||||||
|
|
||||||
ensureDevelopmentMode(req, res, next);
|
ensureDevelopmentMode(req, res, next);
|
||||||
|
|
||||||
|
|
@ -39,8 +40,8 @@ describe('developmentMode middleware', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('passes when enabled and on non-production URL', () => {
|
it('passes when enabled and on non-production URL', () => {
|
||||||
sandbox.stub(nconf, 'get').withArgs('DEBUG_ENABLED').returns(true);
|
nconfStub.withArgs('DEBUG_ENABLED').returns(true);
|
||||||
sandbox.stub(nconf, 'get').withArgs('BASE_URL').returns('http://localhost:3000');
|
nconfStub.withArgs('BASE_URL').returns('http://localhost:3000');
|
||||||
|
|
||||||
ensureDevelopmentMode(req, res, next);
|
ensureDevelopmentMode(req, res, next);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,18 +9,19 @@ import { NotFound } from '../../../../website/server/libs/errors';
|
||||||
import ensureTimeTravelMode from '../../../../website/server/middlewares/ensureTimeTravelMode';
|
import ensureTimeTravelMode from '../../../../website/server/middlewares/ensureTimeTravelMode';
|
||||||
|
|
||||||
describe('timetravelMode middleware', () => {
|
describe('timetravelMode middleware', () => {
|
||||||
let res; let req; let
|
let res; let req; let next;
|
||||||
next;
|
let nconfStub;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
res = generateRes();
|
res = generateRes();
|
||||||
req = generateReq();
|
req = generateReq();
|
||||||
next = generateNext();
|
next = generateNext();
|
||||||
|
nconfStub = sandbox.stub(nconf, 'get');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns not found when using production URL', () => {
|
it('returns not found when using production URL', () => {
|
||||||
sandbox.stub(nconf, 'get').withArgs('TIME_TRAVEL_ENABLED').returns(false);
|
nconfStub.withArgs('TIME_TRAVEL_ENABLED').returns(false);
|
||||||
sandbox.stub(nconf, 'get').withArgs('BASE_URL').returns('https://habitica.com');
|
nconfStub.withArgs('BASE_URL').returns('https://habitica.com');
|
||||||
|
|
||||||
ensureTimeTravelMode(req, res, next);
|
ensureTimeTravelMode(req, res, next);
|
||||||
|
|
||||||
|
|
@ -29,8 +30,8 @@ describe('timetravelMode middleware', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns not found when not in time travel mode', () => {
|
it('returns not found when not in time travel mode', () => {
|
||||||
sandbox.stub(nconf, 'get').withArgs('TIME_TRAVEL_ENABLED').returns(false);
|
nconfStub.withArgs('TIME_TRAVEL_ENABLED').returns(false);
|
||||||
sandbox.stub(nconf, 'get').withArgs('BASE_URL').returns('http://localhost:3000');
|
nconfStub.withArgs('BASE_URL').returns('http://localhost:3000');
|
||||||
|
|
||||||
ensureTimeTravelMode(req, res, next);
|
ensureTimeTravelMode(req, res, next);
|
||||||
|
|
||||||
|
|
@ -39,8 +40,8 @@ describe('timetravelMode middleware', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('passes when in time travel mode', () => {
|
it('passes when in time travel mode', () => {
|
||||||
sandbox.stub(nconf, 'get').withArgs('TIME_TRAVEL_ENABLED').returns(true);
|
nconfStub.withArgs('TIME_TRAVEL_ENABLED').returns(true);
|
||||||
sandbox.stub(nconf, 'get').withArgs('BASE_URL').returns('http://localhost:3000');
|
nconfStub.withArgs('BASE_URL').returns('http://localhost:3000');
|
||||||
|
|
||||||
ensureTimeTravelMode(req, res, next);
|
ensureTimeTravelMode(req, res, next);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue