@@ -5,9 +5,11 @@ var mod = require('../../src/data-structures/red-black-tree.js'),
5
5
RBTree = mod . RBTree ;
6
6
7
7
describe ( 'Node' , function ( ) {
8
+
8
9
it ( 'should be a constructor function' , function ( ) {
9
10
expect ( typeof Node ) . toBe ( 'function' ) ;
10
11
} ) ;
12
+
11
13
it ( 'should set all properties via the constructor' , function ( ) {
12
14
var node = new Node ( 'key' , 'value' , 1 , 2 , true ) ;
13
15
expect ( node . getKey ( ) ) . toBe ( 'key' ) ;
@@ -19,9 +21,20 @@ describe('Node', function () {
19
21
//if we set isRed to falcy it should be turned to red
20
22
expect ( node . isRed ( ) ) . toBe ( false ) ;
21
23
} ) ;
22
- it ( 'should has method flipColor' , function ( ) {
23
- var node = new Node ( ) ;
24
- expect ( typeof node . flipColor ) . toBe ( 'function' ) ;
24
+
25
+ describe ( 'Node flipColor' , function ( ) {
26
+ it ( 'should has method flipColor' , function ( ) {
27
+ var node = new Node ( ) ;
28
+ expect ( typeof node . flipColor ) . toBe ( 'function' ) ;
29
+ } ) ;
30
+ it ( 'should work properly' , function ( ) {
31
+ var node = new Node ( ) ;
32
+ expect ( node . isRed ( ) ) . toBe ( false ) ;
33
+ node . flipColor ( ) ;
34
+ expect ( node . isRed ( ) ) . toBe ( true ) ;
35
+ node . flipColor ( ) ;
36
+ expect ( node . isRed ( ) ) . toBe ( false ) ;
37
+ } ) ;
25
38
} ) ;
26
39
} ) ;
27
40
0 commit comments