UNPKG

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