row_expose_transform.js 857 B

12345678910111213141516171819202122232425262728293031
  1. var parser = require('../');
  2. var test = require('tap').test;
  3. var through = require('through2');
  4. var path = require('path');
  5. // test that (non global) transforms are applied to an exposed module
  6. test('row is exposed and transformed', function (t) {
  7. t.plan(2);
  8. var exposed_path = path.join(__dirname, '/files/main.js');
  9. var found_exposed_path = false;
  10. var opts = {
  11. expose: {},
  12. transform: function(file) {
  13. if (file === exposed_path) {
  14. found_exposed_path = true;
  15. }
  16. return through();
  17. }
  18. };
  19. var p = parser(opts);
  20. p.end({ file: exposed_path, expose: "whatever" });
  21. p.on('error', t.fail.bind(t));
  22. p.pipe(through.obj());
  23. p.on('end', function () {
  24. t.equal(opts.expose.whatever, exposed_path);
  25. t.ok(found_exposed_path);
  26. });
  27. });