1 | 'use strict';
|
2 |
|
3 |
|
4 | var test = require('tap').test
|
5 | , getPacks = require('./util/get-packs')
|
6 | , reset = require('./util/reset')
|
7 | , viralify = require('../')
|
8 |
|
9 | var original = __dirname + '/original'
|
10 | , copy = __dirname + '/copy'
|
11 |
|
12 | function inspect(obj, depth) {
|
13 | console.error(require('util').inspect(obj, false, depth || 5, true));
|
14 | }
|
15 |
|
16 | test('\nviralifying three transforms in different situations', function (t) {
|
17 |
|
18 | reset(original, copy, runTest);
|
19 |
|
20 | function runTest(err) {
|
21 | if (err) { t.fail(err); t.end(); }
|
22 | viralify(copy, [ 'einsify', 'zweiify', 'dreiify' ], function (err) {
|
23 | if (err) return console.error(err);
|
24 |
|
25 | getPacks(copy, function (err, packs) {
|
26 | if (err) { t.fail(err); t.end(); }
|
27 |
|
28 | t.deepEqual(
|
29 | packs
|
30 | , [ { name: 'sub-sub-dep1',
|
31 | description: 'has one transform already',
|
32 | main: 'index.js',
|
33 | browserify:
|
34 | { transform:
|
35 | [ 'unoify',
|
36 | 'einsify',
|
37 | 'zweiify',
|
38 | 'dreiify' ] } },
|
39 | { name: 'sub-dep2',
|
40 | description: 'has no transforms',
|
41 | main: 'index.js',
|
42 | browserify:
|
43 | { transform:
|
44 | [ 'einsify',
|
45 | 'zweiify',
|
46 | 'dreiify' ] } },
|
47 | { name: 'sub-dep1',
|
48 | description: 'Has no transforms',
|
49 | main: 'index.js',
|
50 | browserify:
|
51 | { transform:
|
52 | [ 'einsify',
|
53 | 'zweiify',
|
54 | 'dreiify' ] } },
|
55 | { name: 'original',
|
56 | description: 'root project',
|
57 | main: 'index.js',
|
58 | browserify:
|
59 | { transform:
|
60 | [ 'einsify',
|
61 | 'zweiify',
|
62 | 'dreiify' ] } },
|
63 | { name: 'dep',
|
64 | description: 'dep which itself has two transforms already',
|
65 | main: 'index.js',
|
66 | browserify:
|
67 | { transform:
|
68 | [ 'unoify',
|
69 | 'dosify',
|
70 | 'einsify',
|
71 | 'zweiify',
|
72 | 'dreiify' ] } } ]
|
73 | , 'adds all three transforms to the end in the order they were given'
|
74 | )
|
75 |
|
76 | addToFront();
|
77 | })
|
78 | })
|
79 |
|
80 | function addToFront() {
|
81 | viralify(copy, [ 'einsify', 'zweiify', 'dreiify' ], true, function (err) {
|
82 | if (err) return console.error(err);
|
83 |
|
84 | getPacks(copy, function (err, packs) {
|
85 | if (err) { t.fail(err); t.end(); }
|
86 |
|
87 | t.deepEqual(
|
88 | packs
|
89 | , [ { name: 'sub-sub-dep1',
|
90 | description: 'has one transform already',
|
91 | main: 'index.js',
|
92 | browserify:
|
93 | { transform:
|
94 | [ 'einsify',
|
95 | 'zweiify',
|
96 | 'dreiify',
|
97 | 'unoify' ] } },
|
98 | { name: 'sub-dep2',
|
99 | description: 'has no transforms',
|
100 | main: 'index.js',
|
101 | browserify:
|
102 | { transform:
|
103 | [ 'einsify',
|
104 | 'zweiify',
|
105 | 'dreiify' ] } },
|
106 | { name: 'sub-dep1',
|
107 | description: 'Has no transforms',
|
108 | main: 'index.js',
|
109 | browserify:
|
110 | { transform:
|
111 | [ 'einsify',
|
112 | 'zweiify',
|
113 | 'dreiify' ] } },
|
114 | { name: 'original',
|
115 | description: 'root project',
|
116 | main: 'index.js',
|
117 | browserify:
|
118 | { transform:
|
119 | [ 'einsify',
|
120 | 'zweiify',
|
121 | 'dreiify'] } },
|
122 | { name: 'dep',
|
123 | description: 'dep which itself has two transforms already',
|
124 | main: 'index.js',
|
125 | browserify:
|
126 | { transform:
|
127 | [ 'einsify',
|
128 | 'zweiify',
|
129 | 'dreiify',
|
130 | 'unoify',
|
131 | 'dosify' ] } } ]
|
132 | , 'adds all three transforms to the front in the order they were given and removes them from the end'
|
133 | )
|
134 | t.end();
|
135 | })
|
136 | })
|
137 | }
|
138 | }
|
139 | })
|