UNPKG

437 BJavaScriptView Raw
1var test = require('tap').test;
2var traverse = require('../');
3
4test('leaves test', function (t) {
5 var acc = [];
6 traverse({
7 a : [1,2,3],
8 b : 4,
9 c : [5,6],
10 d : { e : [7,8], f : 9 }
11 }).forEach(function (x) {
12 if (this.isLeaf) acc.push(x);
13 });
14
15 t.equal(
16 acc.join(' '),
17 '1 2 3 4 5 6 7 8 9',
18 'Traversal in the right(?) order'
19 );
20
21 t.end();
22});