mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-30 14:22:07 +03:00
c39df004dc
refs #9742, refs #9724 - handle König Editor format for 2.0 - adapted importer to be able to import 1.0 and 2.0 exports - added migration scripts - remove labs flag for Koenig - migrate all old editor posts to new editor format - ensure we protect the code against mobiledoc or html field being null - ensure we create a blank mobiledoc structure if mobiledoc field is null (model layer) - ensure you can fully rollback 2.0 to 1.0 - keep mobiledoc/markdown version 1 logic to be able to rollback (deprecated code)
51 lines
1.7 KiB
JavaScript
51 lines
1.7 KiB
JavaScript
var should = require('should'),
|
|
helperUtils = require('../../../server/helpers/utils');
|
|
|
|
describe('Helpers Utils', function () {
|
|
describe('Word Count', function () {
|
|
it('[success] can count words', function () {
|
|
var html = 'Some words here',
|
|
result = helperUtils.wordCount(html);
|
|
|
|
result.should.equal(3);
|
|
});
|
|
|
|
it('[success] sanitized HTML tags', function () {
|
|
var html = '<p>This is a text example! Count me in ;)</p>',
|
|
result = helperUtils.wordCount(html);
|
|
|
|
result.should.equal(8);
|
|
});
|
|
|
|
it('[success] sanitized non alpha-numeric characters', function () {
|
|
var html = '<p>This is a text example! I love Döner. Especially number 875.</p>',
|
|
result = helperUtils.wordCount(html);
|
|
|
|
result.should.equal(11);
|
|
});
|
|
|
|
it('[success] counted Chinese characters', function () {
|
|
var html = '<p>我今天在家吃了好多好多好吃的,现在的我非常开心非常满足</p>',
|
|
result = helperUtils.wordCount(html);
|
|
|
|
result.should.equal(26);
|
|
});
|
|
|
|
it('[success] sanitized white space correctly', function () {
|
|
var html = ' <p> This is a text example!\n Count me in ;)</p> ',
|
|
result = helperUtils.wordCount(html);
|
|
|
|
result.should.equal(8);
|
|
});
|
|
});
|
|
|
|
describe('Image Count', function () {
|
|
it('[success] can count images', function () {
|
|
var html = '<p>This is a <img src="hello.png"> text example! Count me in ;)</p><img src="hello.png">',
|
|
result = helperUtils.imageCount(html);
|
|
|
|
result.should.equal(2);
|
|
});
|
|
});
|
|
});
|