UNPKG

1.09 kBJavaScriptView 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, where in the
7// exposed name is identical to the file path.
8test('row is exposed with a name equal to the path, and transformed', function (t) {
9 t.plan(2);
10 var exposed_path = path.join(__dirname, '/files/main.js');
11 var found_exposed_path = false;
12 var opts = {
13 expose: {},
14 transform: function(file) {
15 if (file === exposed_path) {
16 found_exposed_path = true;
17 }
18 return through();
19 }
20 };
21
22 var p = parser(opts);
23 p.end({ file: exposed_path, expose: exposed_path });
24 p.on('error', t.fail.bind(t));
25
26 p.pipe(through.obj());
27
28 p.on('end', function () {
29 t.equal(opts.expose[exposed_path], exposed_path);
30 t.ok(found_exposed_path);
31 });
32});