Skip to content

Commit 9a4588a

Browse files
committed
Add tests
1 parent 9f0cff1 commit 9a4588a

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

test/data-structures/red-black-tree.spec.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ var mod = require('../../src/data-structures/red-black-tree.js'),
55
RBTree = mod.RBTree;
66

77
describe('Node', function () {
8+
89
it('should be a constructor function', function () {
910
expect(typeof Node).toBe('function');
1011
});
12+
1113
it('should set all properties via the constructor', function () {
1214
var node = new Node('key', 'value', 1, 2, true);
1315
expect(node.getKey()).toBe('key');
@@ -19,9 +21,20 @@ describe('Node', function () {
1921
//if we set isRed to falcy it should be turned to red
2022
expect(node.isRed()).toBe(false);
2123
});
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+
});
2538
});
2639
});
2740

0 commit comments

Comments
 (0)