/** * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md. */ import plainTextToHtml from '../../src/utils/plaintexttohtml'; describe( 'plainTextToHtml()', () => { it( 'encodes < and >', () => { expect( plainTextToHtml( 'x y ' ) ).to.equal( 'x y <z>' ); } ); it( 'turns double line breaks into paragraphs', () => { expect( plainTextToHtml( 'x\n\ny\n\nz' ) ).to.equal( '

x

y

z

' ); } ); it( 'turns single line breaks into
s', () => { expect( plainTextToHtml( 'x\ny\nz' ) ).to.equal( 'x
y
z' ); } ); it( 'turns double and single line breaks to a combination of paragraphs and
s', () => { expect( plainTextToHtml( 'a\nb\n\nc\nd' ) ).to.equal( '

a
b

c
d

' ); } ); it( 'turns 3-5 subsequent new lines to a combination of paragraphs and
s', () => { expect( plainTextToHtml( 'a\n\n\nb\n\n\n\nc\n\n\n\n\nd' ) ) .to.equal( '

a


b

c


d

' ); } ); it( 'preserves trailing spaces', () => { expect( plainTextToHtml( ' x ' ) ).to.equal( ' x ' ); } ); it( 'preserve subsequent spaces', () => { expect( plainTextToHtml( 'x y ' ) ).to.equal( 'x  y  ' ); } ); } );