UNPKG

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