/** * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md. */ import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor'; import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph'; import { getData } from '../../../src/dev-utils/model'; describe( 'DomConverter – whitespace handling – integration', () => { let editor; // See https://github.com/ckeditor/ckeditor5-engine/issues/822. describe( 'data loading', () => { beforeEach( () => { return VirtualTestEditor .create( { plugins: [ Paragraph ] } ) .then( newEditor => { editor = newEditor; } ); } ); afterEach( () => { return editor.destroy(); } ); it( 'new line at the end of the content is ignored', () => { editor.setData( '
foo
\n' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
' ); } ); it( 'whitespaces at the end of the content are ignored', () => { editor.setData( 'foo
\n\r\n \t' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
' ); } ); // Controversial result. See https://github.com/ckeditor/ckeditor5-engine/issues/987. it( 'nbsp at the end of the content is not ignored', () => { editor.setData( 'foo
' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
' ); } ); it( 'new line at the beginning of the content is ignored', () => { editor.setData( '\nfoo
' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
' ); } ); it( 'whitespaces at the beginning of the content are ignored', () => { editor.setData( '\n\n \tfoo
' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
' ); } ); // Controversial result. See https://github.com/ckeditor/ckeditor5-engine/issues/987. it( 'nbsp at the beginning of the content is not ignored', () => { editor.setData( 'foo
' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
' ); } ); it( 'new line between blocks is ignored', () => { editor.setData( 'foo
\nbar
' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
bar
' ); } ); it( 'whitespaces between blocks are ignored', () => { editor.setData( 'foo
\n\n \tbar
' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
bar
' ); } ); // Controversial result. See https://github.com/ckeditor/ckeditor5-engine/issues/987. it( 'nbsp between blocks is not ignored', () => { editor.setData( 'foo
bar
' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
bar
' ); } ); it( 'new lines inside blocks are ignored', () => { editor.setData( '\nfoo\n
' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
' ); } ); it( 'whitespaces inside blocks are ignored', () => { editor.setData( '\n\n \tfoo\n\n \t
' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
' ); } ); it( 'nbsp inside blocks are not ignored', () => { editor.setData( 'foo
' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
' ); } ); it( 'all whitespaces together are ignored', () => { editor.setData( '\nfoo\n\r\n \t
\nbar
' ); expect( getData( editor.model, { withoutSelection: true } ) ) .to.equal( 'foo
bar
' ); } ); } ); } );