2020-04-08 21:02:31 +03:00
|
|
|
const should = require('should');
|
|
|
|
const _ = require('lodash');
|
|
|
|
const hbs = require('../../../../../core/frontend/services/themes/engine');
|
2013-09-06 20:07:25 +04:00
|
|
|
|
2020-04-08 21:02:31 +03:00
|
|
|
// Stuff we are testing
|
|
|
|
const helpers = require('../../../../../core/frontend/helpers');
|
2013-07-11 02:45:13 +04:00
|
|
|
|
2014-11-27 23:50:15 +03:00
|
|
|
describe('Helpers', function () {
|
2020-04-29 18:44:27 +03:00
|
|
|
const hbsHelpers = ['each', 'if', 'unless', 'with', 'helperMissing', 'blockHelperMissing', 'log', 'lookup', 'block', 'contentFor'];
|
|
|
|
const ghostHelpers = [
|
|
|
|
'asset', 'author', 'authors', 'body_class', 'cancel_link', 'concat', 'content', 'date', 'encode', 'excerpt', 'facebook_url', 'foreach', 'get',
|
|
|
|
'ghost_foot', 'ghost_head', 'has', 'img_url', 'is', 'lang', 'link', 'link_class', 'meta_description', 'meta_title', 'navigation',
|
|
|
|
'next_post', 'page_url', 'pagination', 'plural', 'post_class', 'prev_post', 'price', 'raw', 'reading_time', 't', 'tags', 'title', 'twitter_url',
|
|
|
|
'url'
|
|
|
|
];
|
|
|
|
|
|
|
|
const expectedHelpers = _.concat(hbsHelpers, ghostHelpers);
|
2017-03-23 22:00:58 +03:00
|
|
|
|
|
|
|
describe('Load Core Helpers', function () {
|
|
|
|
before(function () {
|
2018-08-30 19:17:27 +03:00
|
|
|
hbs.express4();
|
2017-03-23 22:00:58 +03:00
|
|
|
helpers.loadCoreHelpers();
|
|
|
|
});
|
2014-05-22 01:43:54 +04:00
|
|
|
|
2017-03-23 22:00:58 +03:00
|
|
|
// This will work when we finish refactoring
|
2017-04-04 19:07:35 +03:00
|
|
|
it('should have exactly the right helpers', function () {
|
2020-04-29 18:44:27 +03:00
|
|
|
const foundHelpers = _.keys(hbs.handlebars.helpers);
|
|
|
|
const missingHelpers = _.difference(expectedHelpers, foundHelpers);
|
|
|
|
const unexpectedHelpers = _.difference(foundHelpers, expectedHelpers);
|
2014-05-22 01:43:54 +04:00
|
|
|
|
2017-03-23 22:00:58 +03:00
|
|
|
missingHelpers.should.be.an.Array().with.lengthOf(0);
|
|
|
|
unexpectedHelpers.should.be.an.Array().with.lengthOf(0);
|
2014-05-22 01:43:54 +04:00
|
|
|
});
|
|
|
|
});
|
2014-02-08 16:53:28 +04:00
|
|
|
});
|