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

Commit

Permalink
Test for proper order of render event listeners.
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Jasiun committed Feb 20, 2018
1 parent 808618e commit 1200036
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/view/view/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,36 @@ describe( 'view', () => {
sinon.assert.calledTwice( spy );
} );

it( 'should call second render after the first is done', () => {
let called = false;
const order = [];

const lowSpy = sinon.spy( () => {
order.push( 'low1' );

// Prevent infinite loop.
if ( !called ) {
called = true;
view.render();
}

order.push( 'low2' );
} );

const lowestSpy = sinon.spy( () => {
order.push( 'lowest' );
} );

view.on( 'render', lowSpy, { priority: 'low' } );
view.on( 'render', lowestSpy, { priority: 'lowest' } );

view.render();
sinon.assert.calledTwice( lowSpy );
sinon.assert.calledTwice( lowestSpy );

expect( order ).to.deep.equal( [ 'low1', 'low2', 'lowest', 'low1', 'low2', 'lowest' ] );
} );

it( 'should NOT throw when someone tries to call change() before rendering', () => {
view.on( 'render', () => {
expect( () => view.change( () => {} ) ).not.to.throw( CKEditorError, /^applying-view-changes-on-rendering/ );
Expand Down

0 comments on commit 1200036

Please sign in to comment.