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

Commit

Permalink
Tests: added additional test for model.Element#clone( true ).
Browse files Browse the repository at this point in the history
  • Loading branch information
scofalik committed Apr 25, 2017
1 parent ccb0659 commit 66f4e1b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tests/model/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ describe( 'Element', () => {
expect( Array.from( copy.getChildren() ) ).to.deep.equal( [] );
} );

it( 'should clone children, if clone is deep', () => {
let p = new Element( 'p' );
it( 'should clone children (deeply), if clone is deep', () => {
let foo = new Text( 'foo' );
let bar = new Text( 'bar' );
let p = new Element( 'p', null, bar );

let element = new Element( 'elem', { bold: true, italic: true }, [ p, foo ] );
let copy = element.clone( true );
Expand All @@ -86,9 +87,11 @@ describe( 'Element', () => {
expect( copy.childCount ).to.equal( 2 );

expect( copy.getChild( 0 ) ).not.to.equal( p );
expect( copy.getChild( 0 ).getChild( 0 ) ).not.to.equal( bar );
expect( copy.getChild( 1 ) ).not.to.equal( foo );

expect( copy.getChild( 0 ).name ).to.equal( 'p' );
expect( copy.getChild( 0 ).getChild( 0 ).data ).to.equal( 'bar' );
expect( copy.getChild( 1 ).data ).to.equal( 'foo' );
} );
} );
Expand Down

0 comments on commit 66f4e1b

Please sign in to comment.