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

Commit

Permalink
Tests: changed some tests so that there is always some content in mod…
Browse files Browse the repository at this point in the history
…el document.
  • Loading branch information
scofalik committed Apr 26, 2017
1 parent 331242d commit 8795de1
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions tests/listengine.js
Original file line number Diff line number Diff line change
Expand Up @@ -3152,15 +3152,16 @@ describe( 'ListEngine', () => {
} );

it( 'model remove converter should not fire if change was already consumed', () => {
editor.editing.modelToView.on( 'remove', ( evt, data, consumable ) => {
editor.editing.modelToView.on( 'remove:listItem', ( evt, data, consumable ) => {
consumable.consume( data.item, 'remove' );
}, { priority: 'highest' } );

setModelData( modelDoc, '<listItem indent="0" type="bulleted"></listItem>' );
// Paragraph is needed to prevent autoparagraphing of empty editor.
setModelData( modelDoc, '<paragraph>x</paragraph><listItem indent="0" type="bulleted"></listItem>' );

modelDoc.batch().remove( modelRoot.getChild( 0 ) );
modelDoc.batch().remove( modelRoot.getChild( 1 ) );

expect( getViewData( editor.editing.view, { withoutSelection: true } ) ).to.equal( '<ul><li></li></ul>' );
expect( getViewData( editor.editing.view, { withoutSelection: true } ) ).to.equal( '<p>x</p><ul><li></li></ul>' );
} );

it( 'model change type converter should not fire if change was already consumed', () => {
Expand Down Expand Up @@ -3192,19 +3193,19 @@ describe( 'ListEngine', () => {
consumable.consume( data.input, { name: true } );
}, { priority: 'highest' } );

editor.setData( '<ul><li></li></ul>' );
editor.setData( '<p></p><ul><li></li></ul>' );

expect( getModelData( modelDoc, { withoutSelection: true } ) ).to.equal( '' );
expect( getModelData( modelDoc, { withoutSelection: true } ) ).to.equal( '<paragraph></paragraph>' );
} );

it( 'view ul converter should not fire if change was already consumed', () => {
editor.data.viewToModel.on( 'element:ul', ( evt, data, consumable ) => {
consumable.consume( data.input, { name: true } );
}, { priority: 'highest' } );

editor.setData( '<ul><li></li></ul>' );
editor.setData( '<p></p><ul><li></li></ul>' );

expect( getModelData( modelDoc, { withoutSelection: true } ) ).to.equal( '' );
expect( getModelData( modelDoc, { withoutSelection: true } ) ).to.equal( '<paragraph></paragraph>' );
} );

it( 'view converter should pass model document fragment in data.output', () => {
Expand Down

0 comments on commit 8795de1

Please sign in to comment.