UNPKG

1.04 kBJavaScriptView Raw
1var sort = require('../');
2var test = require('tape');
3var through = require('through2');
4
5test('indexed', function (t) {
6 t.plan(1);
7 var s = sort({ index: true });
8 var rows = [];
9 function write (row, enc, next) { rows.push(row); next() }
10 function end () {
11 t.deepEqual(rows, [
12 {
13 id: '/bar.js',
14 deps: {},
15 index: 1,
16 indexDeps: {}
17 },
18 {
19 id: '/foo.js',
20 deps: { './bar': '/bar.js' },
21 index: 2,
22 indexDeps: { './bar': 1 }
23 },
24 {
25 id: '/main.js',
26 deps: { './foo': '/foo.js' },
27 index: 3,
28 indexDeps: { './foo': 2 }
29 },
30 ]);
31 }
32 s.pipe(through.obj(write, end));
33
34 s.write({ id: '/main.js', deps: { './foo': '/foo.js' } });
35 s.write({ id: '/foo.js', deps: { './bar': '/bar.js' } });
36 s.write({ id: '/bar.js', deps: {} });
37 s.end();
38});