/** * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ 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 (Linux/Mac EOL style)', () => { expect( plainTextToHtml( 'x\n\ny\n\nz' ) ).to.equal( '

x

y

z

' ); } ); it( 'turns double line breaks into paragraphs (Windows EOL style)', () => { expect( plainTextToHtml( 'x\r\n\r\ny\r\n\r\nz' ) ).to.equal( '

x

y

z

' ); } ); it( 'turns single line breaks into soft breaks (Linux/Mac EOL style)', () => { expect( plainTextToHtml( 'x\ny\nz' ) ).to.equal( '

x
y
z

' ); } ); it( 'turns single line breaks into soft breaks (Windows EOL style)', () => { expect( plainTextToHtml( 'x\r\ny\r\nz' ) ).to.equal( '

x
y
z

' ); } ); it( 'turns combination of different amount of line breaks to paragraphs', () => { expect( plainTextToHtml( 'a\n\nb\nc\n\n\n\nd\ne' ) ).to.equal( '

a

b
c

d
e

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