expose.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. var sort = require('../');
  2. var test = require('tap').test;
  3. var through = require('through2');
  4. test('expose true', function (t) {
  5. t.plan(1);
  6. var s = sort({ index: true, expose: [ '/foo.js', '/bar.js' ] });
  7. var rows = [];
  8. function write (row, enc, next) { rows.push(row); next() }
  9. function end () {
  10. t.deepEqual(rows, [
  11. {
  12. id: '/bar.js',
  13. deps: {},
  14. index: '/bar.js',
  15. indexDeps: {}
  16. },
  17. {
  18. id: '/foo.js',
  19. deps: { './bar': '/bar.js' },
  20. index: '/foo.js',
  21. indexDeps: { './bar': '/bar.js' }
  22. },
  23. {
  24. id: '/main.js',
  25. deps: { './foo': '/foo.js' },
  26. index: 1,
  27. indexDeps: { './foo': '/foo.js' }
  28. },
  29. ]);
  30. }
  31. s.pipe(through.obj(write, end));
  32. s.write({ id: '/main.js', deps: { './foo': '/foo.js' } });
  33. s.write({ id: '/foo.js', deps: { './bar': '/bar.js' } });
  34. s.write({ id: '/bar.js', deps: {} });
  35. s.end();
  36. });