sort.js 697 B

1234567891011121314151617181920212223
  1. var sort = require('../');
  2. var test = require('tap').test;
  3. var through = require('through2');
  4. test('sort', function (t) {
  5. t.plan(1);
  6. var s = sort();
  7. var rows = [];
  8. function write (row, enc, next) { rows.push(row); next() }
  9. function end () {
  10. t.deepEqual(rows, [
  11. { id: '/bar.js', deps: {} },
  12. { id: '/foo.js', deps: { './bar': '/bar.js' } },
  13. { id: '/main.js', deps: { './foo': '/foo.js' } }
  14. ]);
  15. }
  16. s.pipe(through.obj(write, end));
  17. s.write({ id: '/main.js', deps: { './foo': '/foo.js' } });
  18. s.write({ id: '/foo.js', deps: { './bar': '/bar.js' } });
  19. s.write({ id: '/bar.js', deps: {} });
  20. s.end();
  21. });