plaintexttohtml.js 851 B

12345678910111213141516171819202122232425262728
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import plainTextToHtml from '../../src/utils/plaintexttohtml';
  6. describe( 'plainTextToHtml', () => {
  7. it( 'encodes < and >', () => {
  8. expect( plainTextToHtml( 'x y <z>' ) ).to.equal( 'x y &lt;z&gt;' );
  9. } );
  10. it( 'turns double line breaks into paragraphs', () => {
  11. expect( plainTextToHtml( 'x\n\ny\n\nz' ) ).to.equal( '<p>x</p><p>y</p><p>z</p>' );
  12. } );
  13. it( 'preserves trailing spaces', () => {
  14. expect( plainTextToHtml( ' x ' ) ).to.equal( '&nbsp;x&nbsp;' );
  15. } );
  16. it( 'preserve subsequent spaces', () => {
  17. expect( plainTextToHtml( 'x y ' ) ).to.equal( 'x &nbsp;y &nbsp;' );
  18. } );
  19. it( 'turns single line breaks to spaces', () => {
  20. expect( plainTextToHtml( 'x\ny\nz' ) ).to.equal( 'x y z' );
  21. } );
  22. } );