Ghost/core/test/unit/helpers/content_spec.js
Naz Gargol df7e64fafa
Extracted frontend folder (#10780)
refs #10790

- Moved /core/apps into core/frontend
- Moved /core/server/helpers to /core/frontend/helpers along with /core/server/services/themes
- Changed helper location in overrides
- Moved /core/server/services/routing to /core/frontend/services
- Moved /core/server/services/url to /core/frontend/services
- Moved /core/server/data/meta to /core/frontend/meta
- Moved /core/server/services/rss to /core/frontend/services
- Moved /core/server/data/xml to /core/frontend/services
2019-06-19 11:30:28 +02:00

65 lines
1.9 KiB
JavaScript

var should = require('should'),
// Stuff we are testing
helpers = require('../../../frontend/helpers');
describe('{{content}} helper', function () {
it('renders empty string when null', function () {
var html = null,
rendered = helpers.content.call({html: html});
should.exist(rendered);
rendered.string.should.equal('');
});
it('can render content', function () {
var html = 'Hello World',
rendered = helpers.content.call({html: html});
should.exist(rendered);
rendered.string.should.equal(html);
});
it('can truncate html by word', function () {
var html = '<p>Hello <strong>World! It\'s me!</strong></p>',
rendered = (
helpers.content
.call(
{html: html},
{hash: {words: 2}}
)
);
should.exist(rendered);
rendered.string.should.equal('<p>Hello <strong>World!</strong></p>');
});
it('can truncate html to 0 words', function () {
var html = '<p>Hello <strong>World! It\'s me!</strong></p>',
rendered = (
helpers.content
.call(
{html: html},
{hash: {words: '0'}}
)
);
should.exist(rendered);
rendered.string.should.equal('');
});
it('can truncate html by character', function () {
var html = '<p>Hello <strong>World! It\'s me!</strong></p>',
rendered = (
helpers.content
.call(
{html: html},
{hash: {characters: 8}}
)
);
should.exist(rendered);
rendered.string.should.equal('<p>Hello <strong>Wo</strong></p>');
});
});