mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
7f1d3ebc07
- move all test files from core/test to test/ - updated all imports and other references - all code inside of core/ is then application code - tests are correctly at the root level - consistent with other repos/projects Co-authored-by: Kevin Ansfield <kevin@lookingsideways.co.uk>
64 lines
1.9 KiB
JavaScript
64 lines
1.9 KiB
JavaScript
var should = require('should'),
|
|
|
|
// Stuff we are testing
|
|
helpers = require('../../../core/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>');
|
|
});
|
|
});
|