2014-11-27 23:50:15 +03:00
|
|
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
2017-03-23 22:00:58 +03:00
|
|
|
var should = require('should'), // jshint ignore:line
|
|
|
|
_ = require('lodash'),
|
2017-04-04 19:07:35 +03:00
|
|
|
hbs = require.main.require('core/server/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 () {
|
2017-03-23 22:00:58 +03:00
|
|
|
var hbsHelpers = ['each', 'if', 'unless', 'with', 'helperMissing', 'blockHelperMissing', 'log', 'lookup'],
|
|
|
|
ghostHelpers = [
|
|
|
|
'asset', 'author', 'body_class', 'content', 'date', 'encode', 'excerpt', 'facebook_url', 'foreach', 'get',
|
2017-04-24 20:21:47 +03:00
|
|
|
'ghost_foot', 'ghost_head', 'has', 'img_url', 'is', 'meta_description', 'meta_title', 'navigation',
|
2017-11-06 21:40:07 +03:00
|
|
|
'next_post', 'page_url', 'pagination', 'plural', 'post_class', 'prev_post', 'reading_time', 'tags', 'title', 'twitter_url',
|
2017-03-23 22:00:58 +03:00
|
|
|
'url'
|
|
|
|
],
|
|
|
|
expectedHelpers = _.concat(hbsHelpers, ghostHelpers);
|
|
|
|
|
|
|
|
describe('Load Core Helpers', function () {
|
|
|
|
before(function () {
|
|
|
|
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
|
|
|
});
|