Skip to content

Commit 0d85dfb

Browse files
author
James Halliday
committed
undef file test
1 parent 3c177f8 commit 0d85dfb

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

test/undef_file.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
var parser = require('../');
2+
var test = require('tape');
3+
var fs = require('fs');
4+
var path = require('path');
5+
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+
12+
var sources = Object.keys(files).reduce(function (acc, file) {
13+
acc[file] = fs.readFileSync(files[file], 'utf8');
14+
return acc;
15+
}, {});
16+
17+
test('undef file', function (t) {
18+
t.plan(1);
19+
var p = parser();
20+
p.end({ id: files.main, entry: true });
21+
22+
var rows = [];
23+
p.on('data', function (row) { rows.push(row) });
24+
p.on('end', function () {
25+
t.same(rows.sort(cmp), [
26+
{
27+
id: files.main,
28+
source: sources.main,
29+
entry: true,
30+
deps: { './foo': files.foo }
31+
},
32+
{
33+
id: files.foo,
34+
file: files.foo,
35+
source: sources.foo,
36+
deps: { './bar': files.bar }
37+
},
38+
{
39+
id: files.bar,
40+
file: files.bar,
41+
source: sources.bar,
42+
deps: {}
43+
}
44+
].sort(cmp));
45+
});
46+
});
47+
48+
function cmp (a, b) { return a.id < b.id ? -1 : 1 }

0 commit comments

Comments
 (0)