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

Commit

Permalink
Tests: Move post-fixers calls test to the editing controller tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jodator committed Oct 2, 2018
1 parent 1a1e019 commit abfd48b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 29 deletions.
16 changes: 16 additions & 0 deletions tests/controller/editingcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,22 @@ describe( 'EditingController', () => {
expect( changeListenerSpy.calledOnce ).to.be.true;
} );

it( 'should call view post-fixers once for model.change() block', () => {
const postfixerSpy = sinon.spy();

editing.view.document.registerPostFixer( postfixerSpy );

model.change( writer => {
executeSomeModelChange( writer );

editing.view.change( writer => {
executeSomeViewChange( writer );
} );
} );

sinon.assert.calledOnce( postfixerSpy );
} );

function executeSomeModelChange( writer ) {
const range = new ModelRange( new ModelPosition( modelRoot, [ 0, 1 ] ), new ModelPosition( modelRoot, [ 2, 2 ] ) );
writer.addMarker( 'marker1', { range, usingOperation: true } );
Expand Down
29 changes: 0 additions & 29 deletions tests/view/view/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,35 +396,6 @@ describe( 'view', () => {
} );
} );

describe( 'editing controller integration', () => {
it( 'should call post-fixers once if rendering model changes (_disableRendering integration)', () => {
const postFixerSpy = sinon.spy( () => false );
const changeSpy = sinon.spy();
const eventSpy = sinon.spy();

viewDocument.registerPostFixer( postFixerSpy );

view.on( 'render', eventSpy );

// This is set in editing controller on `model#_beforeChanges` event
view._renderingDisabled = true;

view.change( changeSpy );
view.change( changeSpy );
view.change( changeSpy );

// This is set in editing controller on `model#_afterChanges` event
view._renderingDisabled = false;
view.render();

sinon.assert.calledOnce( postFixerSpy );
sinon.assert.calledThrice( changeSpy );
sinon.assert.calledOnce( eventSpy );

sinon.assert.callOrder( changeSpy, postFixerSpy, eventSpy );
} );
} );

describe( 'view and DOM integration', () => {
it( 'should remove content of the DOM', () => {
const domDiv = createElement( document, 'div', { id: 'editor' }, [
Expand Down

0 comments on commit abfd48b

Please sign in to comment.