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

Commit

Permalink
Tests: 'uiElement' rerendering unit test added.
Browse files Browse the repository at this point in the history
  • Loading branch information
f1ames committed Jun 11, 2018
1 parent c974fbb commit 3a4ffd4
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/view/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ViewAttributeElement from '../../src/view/attributeelement';
import ViewText from '../../src/view/text';
import ViewRange from '../../src/view/range';
import ViewPosition from '../../src/view/position';
import UIElement from '../../src/view/uielement';
import DocumentSelection from '../../src/view/documentselection';
import DomConverter from '../../src/view/domconverter';
import Renderer from '../../src/view/renderer';
Expand Down Expand Up @@ -2948,6 +2949,40 @@ describe( 'Renderer', () => {
'<li style="font-weight:bold;">Ba1 <i style="color:#000;border-width:1px;">Ba3 ' +
'<b style="font-size:15px;">Ba2</b></i></li></ol>' ) );
} );

it( 'should handle uiElement rendering', () => {
function createUIElement( id, text ) {
const element = new UIElement( 'span' );
element.render = function( domDocument ) {
const domElement = this.toDomElement( domDocument );
domElement.innerText = `<span id="${ id }"><b>${ text }</b></span>`;
return domElement;
};

return element;
}

const ui1 = createUIElement( 'id1', 'UI1' );
const ui2 = createUIElement( 'id2', 'UI2' );
const viewP = new ViewContainerElement( 'p', null, [ new ViewText( 'Foo ' ), ui1, new ViewText( 'Bar' ) ] );
viewRoot._appendChild( viewP );

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

expect( normalizeHtml( domRoot.innerHTML ) ).to.equal( normalizeHtml(
'<p>Foo <span><span id="id1"><b>UI1</b></span></span>Bar</p>' ) );

viewP._removeChildren( 0, viewP.childCount );
viewP._insertChild( 0, [ new ViewText( 'Foo' ), ui2, new ViewText( ' Bar' ) ] );

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

expect( normalizeHtml( domRoot.innerHTML ) ).to.equal( normalizeHtml(
'<p>Foo<span><span id="id2"><b>UI2</b></span></span> Bar</p>' ) );
} );
} );
} );

Expand Down

0 comments on commit 3a4ffd4

Please sign in to comment.