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

Commit

Permalink
Tests: Added missing tests to reach 100% CC.
Browse files Browse the repository at this point in the history
  • Loading branch information
scofalik committed Mar 20, 2019
1 parent 45cd071 commit 726af87
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tests/conversion/conversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe( 'Conversion', () => {

upcastDispaA = Symbol( 'upA' );

conversion = new Conversion( [ downcastDispA, downcastDispB ], upcastDispaA );
conversion = new Conversion( [ downcastDispA, downcastDispB ], [ upcastDispaA ] );
} );

describe( 'addAlias()', () => {
Expand Down Expand Up @@ -101,6 +101,21 @@ describe( 'Conversion', () => {
} );
} );

it( 'constructor() should be able to take singular objects instead of arrays', () => {
const helperA = sinon.stub();
const helperB = sinon.stub();

conversion = new Conversion( downcastDispA, upcastDispaA );

conversion.for( 'downcast' ).add( helperA );

expect( helperA.calledWithExactly( downcastDispA ) ).to.be.true;

conversion.for( 'upcast' ).add( helperB );

expect( helperB.calledWithExactly( upcastDispaA ) ).to.be.true;
} );

describe( 'converters', () => {
let viewDispatcher, model, schema, conversion, modelRoot, viewRoot;

Expand Down
18 changes: 18 additions & 0 deletions tests/model/operation/transform/split.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,24 @@ describe( 'transform', () => {
'<paragraph>r</paragraph>'
);
} );

it( 'move operation does not really move anything', () => {
john.setData( '<paragraph>[F]oobar</paragraph>' );
kate.setData( '<paragraph>F[oo]bar</paragraph>' );

john.remove();
john.setSelection( [ 0, 4 ] );
john.split();

kate.move( [ 0, 0 ] );

syncClients();

expectClients(
'<paragraph>ooba</paragraph>' +
'<paragraph>r</paragraph>'
);
} );
} );
} );
} );
37 changes: 37 additions & 0 deletions tests/view/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3252,6 +3252,43 @@ describe( 'Renderer', () => {
] );
} );

it( 'should not incorrectly remove element which is not a FSC when rendering children', () => {
// This test's purpose is mostly reaching 100% CC.
observer = new MutationObserver( () => {} );

viewRoot._appendChild( parse( '<container:div><container:p>1</container:p><container:p>2</container:p></container:div>' ) );

const viewDiv = viewRoot.getChild( 0 );

// Set fake selection on the second paragraph.
selection._setTo( viewDiv.getChild( 1 ), 'on', { fake: true } );

renderer.markToSync( 'children', viewDiv );
renderer.markToSync( 'children', viewRoot );
renderer.render();

observer.observe( domRoot.childNodes[ 0 ], {
childList: true,
attributes: false,
subtree: false
} );

// Remove the second paragraph.
viewDiv._removeChildren( 1, 1 );
// And set the fake selection on the first one.
selection._setTo( viewDiv.getChild( 0 ), 'on', { fake: true } );

renderer.markToSync( 'children', viewDiv );
renderer.markToSync( 'children', viewRoot );
renderer.render();

expect( getMutationStats( observer.takeRecords() ) ).to.deep.equal( [
'added: 0, removed: 1'
] );

observer.disconnect();
} );

describe( 'using fastDiff() - significant number of nodes in the editor', () => {
it( 'should add only one child (at the beginning)', () => {
viewRoot._appendChild( parse( makeContainers( 151 ) ) );
Expand Down

0 comments on commit 726af87

Please sign in to comment.