2020-04-08 19:02:31 +01:00
|
|
|
const should = require('should');
|
2021-03-11 16:30:49 +00:00
|
|
|
const errors = require('@tryghost/errors');
|
|
|
|
const proxy = require('../../../../../core/frontend/services/proxy');
|
2013-11-27 21:45:01 -05:00
|
|
|
|
|
|
|
describe('Helpers Template', function () {
|
2014-06-04 22:26:03 +01:00
|
|
|
it('can execute a template', function () {
|
2021-03-11 16:30:49 +00:00
|
|
|
proxy.hbs.registerPartial('test', '<h1>Hello {{name}}</h1>');
|
2013-11-27 21:45:01 -05:00
|
|
|
|
2021-03-11 16:30:49 +00:00
|
|
|
const safeString = proxy.templates.execute('test', {name: 'world'});
|
2013-11-27 21:45:01 -05:00
|
|
|
|
2013-12-01 18:31:55 -05:00
|
|
|
should.exist(safeString);
|
|
|
|
safeString.should.have.property('string').and.equal('<h1>Hello world</h1>');
|
2013-11-27 21:45:01 -05:00
|
|
|
});
|
2021-03-11 16:30:49 +00:00
|
|
|
|
|
|
|
it('will throw an IncorrectUsageError if the partial does not exist', function () {
|
|
|
|
should.throws(() => {
|
|
|
|
proxy.templates.execute('non-existent');
|
|
|
|
}, errors.IncorrectUsageError);
|
|
|
|
});
|
2014-09-10 00:06:24 -04:00
|
|
|
});
|