2017-03-21 11:24:11 +03:00
|
|
|
var should = require('should'),
|
|
|
|
sinon = require('sinon'),
|
|
|
|
ghostLocals = require('../../../server/middleware/ghost-locals'),
|
|
|
|
|
|
|
|
sandbox = sinon.sandbox.create();
|
2016-10-10 22:14:32 +03:00
|
|
|
|
|
|
|
describe('Theme Handler', function () {
|
|
|
|
var req, res, next;
|
|
|
|
|
|
|
|
beforeEach(function () {
|
2017-03-21 11:24:11 +03:00
|
|
|
req = sandbox.spy();
|
|
|
|
res = sandbox.spy();
|
|
|
|
next = sandbox.spy();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
sandbox.restore();
|
2016-10-10 22:14:32 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
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();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|