mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-19 16:42:17 +03:00
47e00900cc
no issue - change out should.equal for // jshint ignore:line - ensure should is the first require in every test, and ALWAYS require - make sinon the second require, and sandbox the last thing - ALWAYS use sandbox, futureproofs tests against contributors who don't know it - change require formatting
34 lines
863 B
JavaScript
34 lines
863 B
JavaScript
var should = require('should'),
|
|
sinon = require('sinon'),
|
|
ghostLocals = require('../../../server/middleware/ghost-locals'),
|
|
|
|
sandbox = sinon.sandbox.create();
|
|
|
|
describe('Theme Handler', function () {
|
|
var req, res, next;
|
|
|
|
beforeEach(function () {
|
|
req = sandbox.spy();
|
|
res = sandbox.spy();
|
|
next = sandbox.spy();
|
|
});
|
|
|
|
afterEach(function () {
|
|
sandbox.restore();
|
|
});
|
|
|
|
describe('ghostLocals', function () {
|
|
it('sets all locals', function () {
|
|
req.path = '/awesome-post';
|
|
|
|
ghostLocals(req, res, next);
|
|
|
|
res.locals.should.be.an.Object();
|
|
should.exist(res.locals.version);
|
|
should.exist(res.locals.safeVersion);
|
|
res.locals.relativeUrl.should.equal(req.path);
|
|
next.called.should.be.true();
|
|
});
|
|
});
|
|
});
|