main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
374 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var test = require('tape');
|
---|
| 4 | var traverse = require('../');
|
---|
| 5 |
|
---|
| 6 | test('leaves test', function (t) {
|
---|
| 7 | var acc = [];
|
---|
| 8 | traverse({
|
---|
| 9 | a: [1, 2, 3],
|
---|
| 10 | b: 4,
|
---|
| 11 | c: [5, 6],
|
---|
| 12 | d: { e: [7, 8], f: 9 },
|
---|
| 13 | }).forEach(function (x) {
|
---|
| 14 | if (this.isLeaf) { acc.push(x); }
|
---|
| 15 | });
|
---|
| 16 |
|
---|
| 17 | t.equal(
|
---|
| 18 | acc.join(' '),
|
---|
| 19 | '1 2 3 4 5 6 7 8 9',
|
---|
| 20 | 'Traversal in the right(?) order'
|
---|
| 21 | );
|
---|
| 22 |
|
---|
| 23 | t.end();
|
---|
| 24 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.