mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-04-14 19:56:23 +00:00
fix tests
This commit is contained in:
parent
983e01cb3f
commit
550ac2db9d
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', () => {
|
||||
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', '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', 0)).to.equal(false);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -9,18 +9,19 @@ import ensureDevelopmentMode from '../../../../website/server/middlewares/ensure
|
|||
import { NotFound } from '../../../../website/server/libs/errors';
|
||||
|
||||
describe('developmentMode middleware', () => {
|
||||
let res; let req; let
|
||||
next;
|
||||
let res; let req; let next;
|
||||
let nconfStub;
|
||||
|
||||
beforeEach(() => {
|
||||
res = generateRes();
|
||||
req = generateReq();
|
||||
next = generateNext();
|
||||
nconfStub = sandbox.stub(nconf, 'get');
|
||||
});
|
||||
|
||||
it('returns not found when on production URL', () => {
|
||||
sandbox.stub(nconf, 'get').withArgs('DEBUG_ENABLED').returns(true);
|
||||
sandbox.stub(nconf, 'get').withArgs('BASE_URL').returns('https://habitica.com');
|
||||
nconfStub.withArgs('DEBUG_ENABLED').returns(true);
|
||||
nconfStub.withArgs('BASE_URL').returns('https://habitica.com');
|
||||
|
||||
ensureDevelopmentMode(req, res, next);
|
||||
|
||||
|
|
@ -29,8 +30,8 @@ describe('developmentMode middleware', () => {
|
|||
});
|
||||
|
||||
it('returns not found when intentionally disabled', () => {
|
||||
sandbox.stub(nconf, 'get').withArgs('DEBUG_ENABLED').returns(false);
|
||||
sandbox.stub(nconf, 'get').withArgs('BASE_URL').returns('http://localhost:3000');
|
||||
nconfStub.withArgs('DEBUG_ENABLED').returns(false);
|
||||
nconfStub.withArgs('BASE_URL').returns('http://localhost:3000');
|
||||
|
||||
ensureDevelopmentMode(req, res, next);
|
||||
|
||||
|
|
@ -39,8 +40,8 @@ describe('developmentMode middleware', () => {
|
|||
});
|
||||
|
||||
it('passes when enabled and on non-production URL', () => {
|
||||
sandbox.stub(nconf, 'get').withArgs('DEBUG_ENABLED').returns(true);
|
||||
sandbox.stub(nconf, 'get').withArgs('BASE_URL').returns('http://localhost:3000');
|
||||
nconfStub.withArgs('DEBUG_ENABLED').returns(true);
|
||||
nconfStub.withArgs('BASE_URL').returns('http://localhost:3000');
|
||||
|
||||
ensureDevelopmentMode(req, res, next);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,18 +9,19 @@ import { NotFound } from '../../../../website/server/libs/errors';
|
|||
import ensureTimeTravelMode from '../../../../website/server/middlewares/ensureTimeTravelMode';
|
||||
|
||||
describe('timetravelMode middleware', () => {
|
||||
let res; let req; let
|
||||
next;
|
||||
let res; let req; let next;
|
||||
let nconfStub;
|
||||
|
||||
beforeEach(() => {
|
||||
res = generateRes();
|
||||
req = generateReq();
|
||||
next = generateNext();
|
||||
nconfStub = sandbox.stub(nconf, 'get');
|
||||
});
|
||||
|
||||
it('returns not found when using production URL', () => {
|
||||
sandbox.stub(nconf, 'get').withArgs('TIME_TRAVEL_ENABLED').returns(false);
|
||||
sandbox.stub(nconf, 'get').withArgs('BASE_URL').returns('https://habitica.com');
|
||||
nconfStub.withArgs('TIME_TRAVEL_ENABLED').returns(false);
|
||||
nconfStub.withArgs('BASE_URL').returns('https://habitica.com');
|
||||
|
||||
ensureTimeTravelMode(req, res, next);
|
||||
|
||||
|
|
@ -29,8 +30,8 @@ describe('timetravelMode middleware', () => {
|
|||
});
|
||||
|
||||
it('returns not found when not in time travel mode', () => {
|
||||
sandbox.stub(nconf, 'get').withArgs('TIME_TRAVEL_ENABLED').returns(false);
|
||||
sandbox.stub(nconf, 'get').withArgs('BASE_URL').returns('http://localhost:3000');
|
||||
nconfStub.withArgs('TIME_TRAVEL_ENABLED').returns(false);
|
||||
nconfStub.withArgs('BASE_URL').returns('http://localhost:3000');
|
||||
|
||||
ensureTimeTravelMode(req, res, next);
|
||||
|
||||
|
|
@ -39,8 +40,8 @@ describe('timetravelMode middleware', () => {
|
|||
});
|
||||
|
||||
it('passes when in time travel mode', () => {
|
||||
sandbox.stub(nconf, 'get').withArgs('TIME_TRAVEL_ENABLED').returns(true);
|
||||
sandbox.stub(nconf, 'get').withArgs('BASE_URL').returns('http://localhost:3000');
|
||||
nconfStub.withArgs('TIME_TRAVEL_ENABLED').returns(true);
|
||||
nconfStub.withArgs('BASE_URL').returns('http://localhost:3000');
|
||||
|
||||
ensureTimeTravelMode(req, res, next);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue