leaves.js 374 B

123456789101112131415161718192021222324
  1. 'use strict';
  2. var test = require('tape');
  3. var traverse = require('../');
  4. test('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. t.equal(
  15. acc.join(' '),
  16. '1 2 3 4 5 6 7 8 9',
  17. 'Traversal in the right(?) order'
  18. );
  19. t.end();
  20. });