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

Commit

Permalink
Tests: Added a test to check if it is possible to add multiple views …
Browse files Browse the repository at this point in the history
…to ViewCollection at a time.
  • Loading branch information
oleq committed Oct 16, 2019
1 parent 058c211 commit a83676a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/viewcollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,26 @@ describe( 'ViewCollection', () => {
expect( view.id ).to.equal( 1 );
expect( view.viewUid ).to.be.a( 'string' );
} );

it( 'works with multiple views at a time', () => {
const view1 = new View();
view1.element = document.createElement( 'i' );
sinon.spy( view1, 'render' );

const view2 = new View();
view2.element = document.createElement( 'b' );
sinon.spy( view2, 'render' );

const collection = new ViewCollection();
const parentElement = document.createElement( 'div' );

collection.setParent( parentElement );

collection.add( view1, view2 );
expect( normalizeHtml( parentElement.outerHTML ) ).to.equal( '<div><i></i><b></b></div>' );
sinon.assert.calledOnce( view1.render );
sinon.assert.calledOnce( view2.render );
} );
} );

describe( 'setParent()', () => {
Expand Down

0 comments on commit a83676a

Please sign in to comment.