0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-17 23:44:39 -05:00
ghost/test/unit/frontend/services/theme-engine/handlebars/helpers.test.js
Hannah Wolfe 95d27e7f58
Moved frontend unit tests into their own folder
- this is a small part of a bit of cleanup of our test files
- the goal is to make the existing tests clearer with a view to making it easier to write more tests
- this makes the test structure follow the codebase structure more closely
- eventually we will colocate the frontend tests with the frontend code
2021-10-06 11:58:29 +01:00

36 lines
1.7 KiB
JavaScript

const should = require('should');
const _ = require('lodash');
const hbs = require('../../../../../../core/frontend/services/theme-engine/engine');
// Stuff we are testing
const helpers = require('../../../../../../core/frontend/services/helpers');
describe('Helpers', function () {
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 experimentalHelpers = ['match', 'products'];
const expectedHelpers = _.concat(hbsHelpers, ghostHelpers, experimentalHelpers);
describe('Load Core Helpers', function () {
before(function () {
hbs.express4();
helpers.init();
});
// This will work when we finish refactoring
it('should have exactly the right helpers', function () {
const foundHelpers = _.keys(hbs.handlebars.helpers);
const missingHelpers = _.difference(expectedHelpers, foundHelpers);
const unexpectedHelpers = _.difference(foundHelpers, expectedHelpers);
missingHelpers.should.be.an.Array().with.lengthOf(0);
unexpectedHelpers.should.be.an.Array().with.lengthOf(0);
});
});
});