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

Commit

Permalink
Tests: Unit tests for attributes rerendering special case.
Browse files Browse the repository at this point in the history
  • Loading branch information
f1ames committed Oct 1, 2018
1 parent 12ba0df commit e79458b
Showing 1 changed file with 35 additions and 4 deletions.
39 changes: 35 additions & 4 deletions tests/view/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3041,11 +3041,11 @@ describe( 'Renderer', () => {
} );

// #1560
describe( 'direct attributes manipulation', () => {
it( 'should rerender element if its attribute was removed before rendering', () => {
describe( 'attributes manipulation on replaced element', () => {
it( 'should rerender element if it was removed after having its attributes removed (attribute)', () => {
const writer = new DowncastWriter();

// 1. Setup.
// 1. Setup initial view/DOM.
viewRoot._appendChild( parse( '<container:p>1</container:p>' ) );

const viewP = viewRoot.getChild( 0 );
Expand All @@ -3057,18 +3057,49 @@ describe( 'Renderer', () => {

expect( domRoot.innerHTML ).to.equal( '<p data-placeholder="Body">1</p>' );

// 2. Transform.
// 2. Modify view.
writer.removeAttribute( 'data-placeholder', viewP );

viewRoot._removeChildren( 0, viewRoot.childCount );

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

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

expect( domRoot.innerHTML ).to.equal( '<p>1</p><p>2</p>' );
} );

it( 'should rerender element if it was removed after having its attributes removed (classes)', () => {
const writer = new DowncastWriter();

// 1. Setup initial view/DOM.
viewRoot._appendChild( parse( '<container:h1>h1</container:h1><container:p>p</container:p>' ) );

const viewP = viewRoot.getChild( 1 );

writer.addClass( [ 'cke-test1', 'cke-test2' ], viewP );

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

expect( domRoot.innerHTML ).to.equal( '<h1>h1</h1><p class="cke-test1 cke-test2">p</p>' );

// 2. Modify view.
writer.removeClass( 'cke-test2', viewP );

viewRoot._removeChildren( 0, viewRoot.childCount );

viewRoot._appendChild( parse( '<container:h1>h1</container:h1>' +
'<container:p class="cke-test1">p</container:p><container:p>p2</container:p>' ) );

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

expect( domRoot.innerHTML ).to.equal( '<h1>h1</h1><p class="cke-test1">p</p><p>p2</p>' );
} );
} );
} );

Expand Down

0 comments on commit e79458b

Please sign in to comment.