Ghost/core/test/unit/middleware/ghost-locals_spec.js
Hannah Wolfe 47e00900cc 💄 🐷 Test consistency (#8199)
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
2017-03-21 09:24:11 +01:00

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();
});
});
});