2018-06-02 22:48:23 +03:00
|
|
|
var should = require('should'),
|
2014-10-10 18:54:07 +04:00
|
|
|
|
|
|
|
// Stuff we are testing
|
2017-03-21 11:24:11 +03:00
|
|
|
helpers = require('../../../server/helpers');
|
2014-10-10 18:54:07 +04:00
|
|
|
|
|
|
|
describe('{{content}} helper', function () {
|
|
|
|
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(
|
2017-03-21 11:24:11 +03:00
|
|
|
{html: html},
|
|
|
|
{hash: {words: 2}}
|
|
|
|
)
|
|
|
|
);
|
2014-10-10 18:54:07 +04:00
|
|
|
|
|
|
|
should.exist(rendered);
|
2014-11-09 04:32:43 +03:00
|
|
|
rendered.string.should.equal('<p>Hello <strong>World!</strong></p>');
|
2014-10-10 18:54:07 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('can truncate html to 0 words', function () {
|
|
|
|
var html = '<p>Hello <strong>World! It\'s me!</strong></p>',
|
|
|
|
rendered = (
|
|
|
|
helpers.content
|
|
|
|
.call(
|
2017-03-21 11:24:11 +03:00
|
|
|
{html: html},
|
|
|
|
{hash: {words: '0'}}
|
|
|
|
)
|
|
|
|
);
|
2014-10-10 18:54:07 +04:00
|
|
|
|
|
|
|
should.exist(rendered);
|
2017-03-14 16:56:46 +03:00
|
|
|
rendered.string.should.equal('');
|
2014-10-10 18:54:07 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('can truncate html by character', function () {
|
|
|
|
var html = '<p>Hello <strong>World! It\'s me!</strong></p>',
|
|
|
|
rendered = (
|
|
|
|
helpers.content
|
|
|
|
.call(
|
2017-03-21 11:24:11 +03:00
|
|
|
{html: html},
|
|
|
|
{hash: {characters: 8}}
|
|
|
|
)
|
|
|
|
);
|
2014-10-10 18:54:07 +04:00
|
|
|
|
|
|
|
should.exist(rendered);
|
|
|
|
rendered.string.should.equal('<p>Hello <strong>Wo</strong></p>');
|
|
|
|
});
|
|
|
|
});
|