dedupe_undef.js 934 B

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