-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
28 lines (20 loc) · 664 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var leetcode = require('./');
var deepEqual = require('assert').deepEqual;
var tree = leetcode.Tree;
var TreeNode = tree.node;
describe('Tree', function() {
it('test without `null`', function() {
var expected = new TreeNode(1);
var left = new TreeNode(2);
left.left = new TreeNode(4);
expected.left = left;
expected.right = new TreeNode(3);
deepEqual(tree.create([1, 2, 3, 4]), expected)
});
it('test with `null` in source array', function() {
var expected = new TreeNode(1);
expected.right = new TreeNode(2);
expected.right.left = new TreeNode(3);
deepEqual(tree.create([1, null, 2, 3]), expected)
});
});