df7e64fafa
refs #10790 - Moved /core/apps into core/frontend - Moved /core/server/helpers to /core/frontend/helpers along with /core/server/services/themes - Changed helper location in overrides - Moved /core/server/services/routing to /core/frontend/services - Moved /core/server/services/url to /core/frontend/services - Moved /core/server/data/meta to /core/frontend/meta - Moved /core/server/services/rss to /core/frontend/services - Moved /core/server/data/xml to /core/frontend/services
70 lines
1.8 KiB
JavaScript
70 lines
1.8 KiB
JavaScript
var should = require('should'),
|
|
sinon = require('sinon'),
|
|
helpers = require('../../../frontend/helpers'),
|
|
common = require('../../../server/lib/common');
|
|
|
|
describe('{{#is}} helper', function () {
|
|
afterEach(function () {
|
|
sinon.restore();
|
|
});
|
|
|
|
// All positive tests
|
|
it('should match single context "index"', function () {
|
|
var fn = sinon.spy(),
|
|
inverse = sinon.spy();
|
|
|
|
helpers.is.call(
|
|
{},
|
|
'index',
|
|
{fn: fn, inverse: inverse, data: {root: {context: ['home', 'index']}}}
|
|
);
|
|
|
|
fn.called.should.be.true();
|
|
inverse.called.should.be.false();
|
|
});
|
|
|
|
it('should match OR context "index, paged"', function () {
|
|
var fn = sinon.spy(),
|
|
inverse = sinon.spy();
|
|
|
|
helpers.is.call(
|
|
{},
|
|
'index, paged',
|
|
{fn: fn, inverse: inverse, data: {root: {context: ['tag', 'paged']}}}
|
|
);
|
|
|
|
fn.called.should.be.true();
|
|
inverse.called.should.be.false();
|
|
});
|
|
|
|
it('should not match "paged"', function () {
|
|
var fn = sinon.spy(),
|
|
inverse = sinon.spy();
|
|
|
|
helpers.is.call(
|
|
{},
|
|
'paged',
|
|
{fn: fn, inverse: inverse, data: {root: {context: ['index', 'home']}}}
|
|
);
|
|
|
|
fn.called.should.be.false();
|
|
inverse.called.should.be.true();
|
|
});
|
|
|
|
it('should log warning with no args', function () {
|
|
var fn = sinon.spy(),
|
|
inverse = sinon.spy(),
|
|
logWarn = sinon.stub(common.logging, 'warn');
|
|
|
|
helpers.is.call(
|
|
{},
|
|
undefined,
|
|
{fn: fn, inverse: inverse, data: {root: {context: ['index', 'home']}}}
|
|
);
|
|
|
|
logWarn.called.should.be.true();
|
|
fn.called.should.be.false();
|
|
inverse.called.should.be.false();
|
|
});
|
|
});
|