Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Added more tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Feb 26, 2018
1 parent 83e800a commit a6c8512
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/model/writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,37 @@ describe( 'Writer', () => {
expect( parent.childCount ).to.equal( 0 );
} );

it( 'should skip (normalize) an empty text node when inserting an array of text nodes', () => {
const parent = createDocumentFragment();

model.enqueueChange( batch, writer => {
const text1 = writer.createText( 'ab' );
const text2 = writer.createText( '' );
const text3 = writer.createText( 'cd' );

writer.insert( [ text1, text2, text3 ], parent );
} );

expect( parent.childCount ).to.equal( 1 );
expect( parent.getChild( 0 ).data ).to.equal( 'abcd' );
} );

it( 'should skip (normalize) an empty text node when inserting an array of text nodes (different attributes)', () => {
const parent = createDocumentFragment();

model.enqueueChange( batch, writer => {
const text1 = writer.createText( 'ab' );
const text2 = writer.createText( '' );
const text3 = writer.createText( 'cd', { bold: true } );

writer.insert( [ text1, text2, text3 ], parent );
} );

expect( parent.childCount ).to.equal( 2 );
expect( parent.getChild( 0 ).data ).to.equal( 'ab' );
expect( parent.getChild( 1 ).data ).to.equal( 'cd' );
} );

it( 'should create proper delta for inserting element', () => {
const parent = createDocumentFragment();
const element = createElement( 'child' );
Expand Down

0 comments on commit a6c8512

Please sign in to comment.