Files
habitica/test/api/v3/unit/middlewares/ensureDevelpmentMode.js
Matteo Pagliazzi 60f34dafb0 Deprecate API v2 (was Revert "Revert "Deprecate API v2"") (#7802)
* Revert "Revert "Deprecate API v2""

* fix path in shops controller
2016-08-01 22:36:10 +02:00

37 lines
975 B
JavaScript

/* eslint-disable global-require */
import {
generateRes,
generateReq,
generateNext,
} from '../../../../helpers/api-unit.helper';
import ensureDevelpmentMode from '../../../../../website/server/middlewares/ensureDevelpmentMode';
import { NotFound } from '../../../../../website/server/libs/errors';
import nconf from 'nconf';
describe('developmentMode middleware', () => {
let res, req, next;
beforeEach(() => {
res = generateRes();
req = generateReq();
next = generateNext();
});
it('returns not found when in production mode', () => {
sandbox.stub(nconf, 'get').withArgs('IS_PROD').returns(true);
ensureDevelpmentMode(req, res, next);
expect(next).to.be.calledWith(new NotFound());
});
it('passes when not in production', () => {
sandbox.stub(nconf, 'get').withArgs('IS_PROD').returns(false);
ensureDevelpmentMode(req, res, next);
expect(next).to.be.calledOnce;
expect(next.args[0]).to.be.empty;
});
});