-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtraverseDepthFirst.spec.js
34 lines (32 loc) · 1.14 KB
/
traverseDepthFirst.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
var { expect } = require('chai')
const { List } = require('immutable')
const traverseDepthFirst = require('./traverseDepthFirst')
describe('traverseDepthFirst()', function() {
it('should traverse depth first', function() {
expect(
new List().withMutations(mutable =>
traverseDepthFirst(
{
nodeId: 'a0',
parentChildrenMap: this.parentChildrenMap,
},
nodeId => mutable.push(nodeId)
)
)
).to.equal(new List(['a0', 'b1', 'd2', 'c2', 'a1', 'b2', 'b3', 'a3', 'a2']))
})
it('should traverse depth first to depth', function() {
expect(
new List().withMutations(mutable =>
traverseDepthFirst(
{
depth: 2,
nodeId: 'a0',
parentChildrenMap: this.parentChildrenMap,
},
nodeId => mutable.push(nodeId)
)
)
).to.equal(new List(['a0', 'b1', 'd2', 'c2', 'a1', 'b2', 'a2']))
})
})