const should = require('should'); const getExcerpt = require('../../../../core/frontend/meta/excerpt'); describe('getExcerpt', function () { it('should return html excerpt with no html', function () { const html = '
There are
10
types
of people in the world:' +
' those who ' +
'understand trinary,
Testing1, ' + 'my footnotes. And stuff. Footnote2with a link ' + 'right after.'; const expected = 'Testing, my footnotes. And stuff. Footnotewith a link right after.'; getExcerpt(html, {}).should.equal(expected); }); it('should return html excerpt striping inline and bottom footnotes', function () { const html = '
Testing1' + ' a very short post with a single footnote.
\n' + '' + 'https://ghost.org ↩
Hello World! It\'s me!
'; const expected = 'Hello World!'; getExcerpt(html, {words: '2'}).should.equal(expected); }); it('should return html excerpt truncated by words with non-ascii characters', function () { const html = 'Едквюэ опортэат праэчынт ючю но, квуй эю
'; const expected = 'Едквюэ опортэат'; getExcerpt(html, {words: '2'}).should.equal(expected); }); it('should return html excerpt truncated by character', function () { const html = 'Hello World! It\'s me!
'; const expected = 'Hello Wo'; getExcerpt(html, {characters: '8'}).should.equal(expected); }); it('should fall back to 50 words if not specified', function () { const html = 'There are
10
types
of people in the world:' +
' those who ' +
'understand trinary,