UNPKG

1.38 kBJavaScriptView Raw
1var sort = require('../');
2var test = require('tape');
3var through = require('through2');
4
5test('dedupe index', function (t) {
6 t.plan(1);
7 var s = sort({ dedupe: true, 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 source: 'TWO',
16 index: 1,
17 indexDeps: {}
18 },
19 {
20 id: '/foo.js',
21 deps: {},
22 source: 'TWO',
23 dedupe: '/bar.js',
24 index: 2,
25 indexDeps: {},
26 dedupeIndex: 1,
27 sameDeps: true
28 },
29 {
30 id: '/main.js',
31 deps: { './foo': '/foo.js', './bar': '/bar.js' },
32 source: 'ONE',
33 index: 3,
34 indexDeps: { './foo': 2, './bar': 1 },
35 }
36 ]);
37 }
38 s.pipe(through.obj(write, end));
39
40 s.write({
41 id: '/main.js',
42 deps: { './foo': '/foo.js', './bar': '/bar.js' },
43 source: 'ONE'
44 });
45 s.write({
46 id: '/foo.js',
47 deps: {},
48 source: 'TWO'
49 });
50 s.write({
51 id: '/bar.js',
52 deps: {},
53 source: 'TWO'
54 });
55 s.end();
56});