row_expose.js 792 B

123456789101112131415161718192021222324
  1. var parser = require('../');
  2. var test = require('tap').test;
  3. var through = require('through2');
  4. var path = require('path');
  5. // Test that p.options.expose is defined and that the row is properly exposed
  6. // (resolved to the absolute pathname corresponding to the `file` value passed
  7. // in the row, and set in opts.expose).
  8. test('row is exposed', function (t) {
  9. t.plan(1);
  10. var common_path = path.join(__dirname, '/files/main');
  11. var opts = { expose: {} };
  12. var p = parser(opts);
  13. // Note pathname without extension.
  14. p.end({ file: common_path, expose: "whatever" });
  15. p.on('error', t.fail.bind(t));
  16. p.pipe(through.obj());
  17. p.on('end', function () {
  18. // Note pathname with extension.
  19. t.equal(opts.expose.whatever, common_path + '.js');
  20. });
  21. });