noparse_row.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. var parser = require('../');
  2. var test = require('tap').test;
  3. var fs = require('fs');
  4. var concat = require('concat-stream');
  5. var path = require('path');
  6. var files = {
  7. main: path.join(__dirname, '/files/main.js'),
  8. foo: path.join(__dirname, '/files/foo.js'),
  9. bar: path.join(__dirname, '/files/bar.js')
  10. };
  11. var sources = Object.keys(files).reduce(function (acc, file) {
  12. acc[file] = fs.readFileSync(files[file], 'utf8');
  13. return acc;
  14. }, {});
  15. test('noParse row', function (t) {
  16. t.plan(1);
  17. var p = parser();
  18. p.end({ file: files.main, noparse: true });
  19. var rows = [];
  20. p.on('data', function (row) { rows.push(row) });
  21. p.on('end', function () {
  22. t.deepEqual(rows.sort(cmp), [
  23. {
  24. id: files.main,
  25. file: files.main,
  26. source: sources.main,
  27. entry: true,
  28. noparse: true,
  29. deps: {}
  30. }
  31. ].sort(cmp));
  32. });
  33. });
  34. function cmp (a, b) { return a.id < b.id ? -1 : 1 }