UNPKG

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