-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathdefault-keys-spec.js
executable file
·84 lines (71 loc) · 1.83 KB
/
default-keys-spec.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
const LTT = require('../dist/list-to-tree');
describe('Default keys:', function() {
var tree = null;
beforeEach(function() {
var list = [
{
id: 1,
parent: 0
}, {
id: 2,
parent: 1
}, {
id: 3,
parent: 1
}, {
id: 4,
parent: 2
}, {
id: 5,
parent: 2
}, {
id: 6,
parent: 0
}, {
id: 7,
parent: 0
}, {
id: 8,
parent: 7
}, {
id: 9,
parent: 8
}, {
id: 10,
parent: 0
}
];
var ltt = new LTT(list);
tree = ltt.GetTree();
});
it('It is workly', function() {
expect( tree.length ).toBe(4);
});
it('First node check id', function() {
var firstNode = tree[0];
expect( firstNode.id ).toBe(1);
});
it('First node check parent', function() {
var firstNode = tree[0];
expect( firstNode.parent ).toBe(0);
});
it('First node check child', function() {
var child = tree[0].child;
expect( child.length ).toBe(2);
});
it('First child - check id', function() {
var child = tree[0].child;
var node = child[0];
expect( node.id ).toBe(2);
});
it('First child - check parent', function() {
var child = tree[0].child;
var node = child[0];
expect( node.parent ).toBe(1);
});
it('Child node have a child key', function() {
var child = tree[0].child;
var node = child[0];
expect( 'child' in node ).toBe(true);
});
});