Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80529 views
1
var sort = require('../');
2
var test = require('tap').test;
3
var through = require('through2');
4
5
test('expose string', function (t) {
6
t.plan(1);
7
var s = sort({
8
index: true,
9
expose: {
10
'f': '/foo.js',
11
'b': '/bar.js'
12
}
13
});
14
var rows = [];
15
function write (row, enc, next) { rows.push(row); next() }
16
function end () {
17
t.deepEqual(rows, [
18
{
19
id: '/main.js',
20
deps: { './foo': '/foo.js' },
21
index: 1,
22
indexDeps: { './foo': 'f' }
23
},
24
{
25
id: 'b',
26
deps: {},
27
index: 'b',
28
indexDeps: {}
29
},
30
{
31
id: 'f',
32
deps: { './bar': '/bar.js' },
33
index: 'f',
34
indexDeps: { './bar': 'b' }
35
}
36
]);
37
}
38
s.pipe(through.obj(write, end));
39
40
s.write({ id: '/main.js', deps: { './foo': '/foo.js' } });
41
s.write({ id: 'f', deps: { './bar': '/bar.js' } });
42
s.write({ id: 'b', deps: {} });
43
s.end();
44
});
45
46