@@ -29,6 +29,9 @@ describe('AvlTree', () => {
2929 expect ( n . toValues ( ) ) . toMatchObject ( {
3030 value : 2 , left : 1 , right : 3 , parent : null ,
3131 } ) ;
32+
33+ expect ( tree . toArray ( ) ) . toEqual ( [ 2 , 1 , 3 , null , null , null , null ] ) ;
34+ expect ( tree . root ) . toBe ( n ) ;
3235 } ) ;
3336
3437 it ( 'should rebalance desc inserted nodes (RR Rotation)' , ( ) => {
@@ -39,6 +42,7 @@ describe('AvlTree', () => {
3942 expect ( n . toValues ( ) ) . toMatchObject ( {
4043 value : 2 , left : 1 , right : 3 , parent : null ,
4144 } ) ;
45+ expect ( tree . root ) . toBe ( n ) ;
4246 } ) ;
4347
4448 it ( 'should rebalance with LR Rotation' , ( ) => {
@@ -49,6 +53,7 @@ describe('AvlTree', () => {
4953 expect ( n . toValues ( ) ) . toMatchObject ( {
5054 value : 2 , left : 1 , right : 3 , parent : null ,
5155 } ) ;
56+ expect ( tree . root ) . toBe ( n ) ;
5257 } ) ;
5358
5459
@@ -60,6 +65,7 @@ describe('AvlTree', () => {
6065 expect ( n . toValues ( ) ) . toMatchObject ( {
6166 value : 2 , left : 1 , right : 3 , parent : null ,
6267 } ) ;
68+ expect ( tree . root ) . toBe ( n ) ;
6369 } ) ;
6470
6571 it ( 'should not balance' , ( ) => {
@@ -90,6 +96,9 @@ describe('AvlTree', () => {
9096 expect ( n . toValues ( ) ) . toMatchObject ( {
9197 value : 2 , left : 1 , right : 3 , parent : null ,
9298 } ) ;
99+
100+ expect ( tree . root ) . toBe ( n ) ;
101+ expect ( tree . toArray ( ) ) . toEqual ( [ 2 , 1 , 3 , null , null , null , null ] ) ;
93102 } ) ;
94103
95104 it ( 'should rebalance desc inserted nodes (RR Rotation)' , ( ) => {
@@ -103,6 +112,7 @@ describe('AvlTree', () => {
103112 expect ( n . toValues ( ) ) . toMatchObject ( {
104113 value : 2 , left : 1 , right : 3 , parent : null ,
105114 } ) ;
115+ expect ( tree . root ) . toBe ( n ) ;
106116 } ) ;
107117
108118 it ( 'should rebalance with LR Rotation' , ( ) => {
@@ -116,6 +126,7 @@ describe('AvlTree', () => {
116126 expect ( n . toValues ( ) ) . toMatchObject ( {
117127 value : 2 , left : 1 , right : 3 , parent : null ,
118128 } ) ;
129+ expect ( tree . root ) . toBe ( n ) ;
119130 } ) ;
120131
121132
@@ -130,6 +141,7 @@ describe('AvlTree', () => {
130141 expect ( n . toValues ( ) ) . toMatchObject ( {
131142 value : 2 , left : 1 , right : 3 , parent : null ,
132143 } ) ;
144+ expect ( tree . root ) . toBe ( n ) ;
133145 } ) ;
134146 } ) ;
135147} ) ;
0 commit comments