2020-04-29 18:44:27 +03:00
|
|
|
const should = require('should');
|
2014-10-10 18:54:07 +04:00
|
|
|
|
2020-04-29 18:44:27 +03:00
|
|
|
// Stuff we are testing
|
2021-10-06 12:52:46 +03:00
|
|
|
const title = require('../../../../core/frontend/helpers/title');
|
2014-10-10 18:54:07 +04:00
|
|
|
|
|
|
|
describe('{{title}} Helper', function () {
|
|
|
|
it('can render title', function () {
|
2021-10-04 18:30:54 +03:00
|
|
|
const rendered = title.call({title: 'Hello World'});
|
2014-10-10 18:54:07 +04:00
|
|
|
|
|
|
|
should.exist(rendered);
|
2021-10-04 18:30:54 +03:00
|
|
|
rendered.string.should.equal('Hello World');
|
2014-10-10 18:54:07 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('escapes correctly', function () {
|
2021-10-04 18:30:54 +03:00
|
|
|
const rendered = title.call({title: '<h1>I am a title</h1>'});
|
2014-10-10 18:54:07 +04:00
|
|
|
|
|
|
|
rendered.string.should.equal('<h1>I am a title</h1>');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('returns a blank string where title is missing', function () {
|
2021-10-04 18:30:54 +03:00
|
|
|
const rendered = title.call({title: null});
|
2014-10-10 18:54:07 +04:00
|
|
|
|
|
|
|
rendered.string.should.equal('');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('returns a blank string where data missing', function () {
|
2021-10-04 18:30:54 +03:00
|
|
|
const rendered = title.call({});
|
2014-10-10 18:54:07 +04:00
|
|
|
|
|
|
|
rendered.string.should.equal('');
|
|
|
|
});
|
|
|
|
});
|