2018-06-02 22:48:23 +03:00
|
|
|
var should = require('should'),
|
2017-03-23 22:00:58 +03:00
|
|
|
_ = require('lodash'),
|
2017-12-14 05:01:23 +03:00
|
|
|
hbs = require.main.require('core/server/services/themes/engine'),
|
2013-09-06 20:07:25 +04:00
|
|
|
|
|
|
|
// Stuff we are testing
|
2017-03-23 22:00:58 +03:00
|
|
|
helpers = require.main.require('core/server/helpers');
|
2013-07-11 02:45:13 +04:00
|
|
|
|
2014-11-27 23:50:15 +03:00
|
|
|
describe('Helpers', function () {
|
2018-08-30 19:17:27 +03:00
|
|
|
var hbsHelpers = ['each', 'if', 'unless', 'with', 'helperMissing', 'blockHelperMissing', 'log', 'lookup', 'block', 'contentFor'],
|
2017-03-23 22:00:58 +03:00
|
|
|
ghostHelpers = [
|
2018-03-27 17:16:15 +03:00
|
|
|
'asset', 'author', 'authors', 'body_class', 'content', 'date', 'encode', 'excerpt', 'facebook_url', 'foreach', 'get',
|
2018-01-09 16:50:57 +03:00
|
|
|
'ghost_foot', 'ghost_head', 'has', 'img_url', 'is', 'lang', 'meta_description', 'meta_title', 'navigation',
|
|
|
|
'next_post', 'page_url', 'pagination', 'plural', 'post_class', 'prev_post', 'reading_time', 't', 'tags', 'title', 'twitter_url',
|
2017-03-23 22:00:58 +03:00
|
|
|
'url'
|
|
|
|
],
|
|
|
|
expectedHelpers = _.concat(hbsHelpers, ghostHelpers);
|
|
|
|
|
|
|
|
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 () {
|
2017-03-23 22:00:58 +03:00
|
|
|
var foundHelpers, missingHelpers, unexpectedHelpers;
|
2014-05-22 01:43:54 +04:00
|
|
|
|
2017-03-23 22:00:58 +03:00
|
|
|
foundHelpers = _.keys(hbs.handlebars.helpers);
|
2014-05-22 01:43:54 +04:00
|
|
|
|
2017-03-23 22:00:58 +03:00
|
|
|
missingHelpers = _.difference(expectedHelpers, foundHelpers);
|
|
|
|
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
|
|
|
});
|