|
|
@@ -64,18 +64,37 @@ describe( 'Node', () => {
|
|
|
expect( result.length ).to.equal( 0 );
|
|
|
} );
|
|
|
|
|
|
+ it( 'should return array including node itself if requested', () => {
|
|
|
+ const result = root.getAncestors( true );
|
|
|
+ expect( result ).to.be.an( 'array' );
|
|
|
+ expect( result.length ).to.equal( 1 );
|
|
|
+ expect( result[ 0 ] ).to.equal( root );
|
|
|
+ } );
|
|
|
+
|
|
|
it( 'should return array of ancestors', () => {
|
|
|
const result = charR.getAncestors();
|
|
|
expect( result.length ).to.equal( 2 );
|
|
|
expect( result[ 0 ] ).to.equal( root );
|
|
|
expect( result[ 1 ] ).to.equal( two );
|
|
|
+
|
|
|
+ const result2 = charR.getAncestors( true );
|
|
|
+ expect( result2.length ).to.equal( 3 );
|
|
|
+ expect( result2[ 0 ] ).to.equal( root );
|
|
|
+ expect( result2[ 1 ] ).to.equal( two );
|
|
|
+ expect( result2[ 2 ] ).to.equal( charR );
|
|
|
} );
|
|
|
|
|
|
it( 'should return array of ancestors starting from parent', () => {
|
|
|
- const result = charR.getAncestors( true );
|
|
|
+ const result = charR.getAncestors( false, true );
|
|
|
expect( result.length ).to.equal( 2 );
|
|
|
expect( result[ 0 ] ).to.equal( two );
|
|
|
expect( result[ 1 ] ).to.equal( root );
|
|
|
+
|
|
|
+ const result2 = charR.getAncestors( true, true );
|
|
|
+ expect( result2.length ).to.equal( 3 );
|
|
|
+ expect( result2[ 2 ] ).to.equal( root );
|
|
|
+ expect( result2[ 1 ] ).to.equal( two );
|
|
|
+ expect( result2[ 0 ] ).to.equal( charR );
|
|
|
} );
|
|
|
} );
|
|
|
|