Ghost/test/unit/helpers/is_spec.js
Vikas Potluri 00c324fa4e
Moved core/server/lib/common/logging to core/shared/logging (#11857)
- Represents that logging is shared across all parts of Ghost at present
  * moved core/server/lib/common/logging to core/shared/logging
  * updated logging path for generic imports
  * updated migration and schema imports of logging
  * updated tests and index logging import
  * 🔥 removed logging from common module
  * fixed tests
2020-05-28 19:30:23 +01:00

69 lines
1.8 KiB
JavaScript

const sinon = require('sinon');
const helpers = require('../../../core/frontend/helpers');
const logging = require('../../../core/shared/logging');
describe('{{#is}} helper', function () {
afterEach(function () {
sinon.restore();
});
// All positive tests
it('should match single context "index"', function () {
const fn = sinon.spy();
const 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 () {
const fn = sinon.spy();
const 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 () {
const fn = sinon.spy();
const 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 () {
const fn = sinon.spy();
const inverse = sinon.spy();
const logWarn = sinon.stub(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();
});
});