leaves.js 433 B

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