Skip to content

Commit 28680c9

Browse files
committed
add tests for others and new transforms
1 parent b416d9c commit 28680c9

20 files changed

Lines changed: 921 additions & 64 deletions

lib/init/transformations/devServer/devServer.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,7 @@ module.exports = function devServerTransform(
6161
});
6262
return ast;
6363
});
64-
} else if (
65-
devServerNode.size() !== 0 &&
66-
typeof webpackProperties.length
67-
) {
64+
} else if (devServerNode.size() !== 0 && webpackProperties.length) {
6865
return ast
6966
.find(j.ObjectExpression)
7067
.filter(

lib/init/transformations/entry/entry.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ module.exports = function entryTransform(j, ast, webpackProperties, action) {
5757
});
5858
return ast;
5959
});
60-
} else if (entryNode.size() !== 0 && typeof webpackProperties.length) {
60+
} else if (entryNode.size() !== 0 && webpackProperties.length) {
6161
return ast
6262
.find(j.ObjectExpression)
6363
.filter(

lib/init/transformations/externals/externals.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ module.exports = function externalsTransform(
8181
Array.isArray(webpackProperties)
8282
) {
8383
// Todo
84-
} else if (externalNode.size() !== 0 && typeof webpackProperties.length) {
84+
} else if (externalNode.size() !== 0 && webpackProperties.length) {
8585
return ast
8686
.find(j.ObjectExpression)
8787
.filter(

lib/init/transformations/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ const bailTransform = require("./other/bail");
2424
const cacheTransform = require("./other/cache");
2525
const profileTransform = require("./other/profile");
2626
const mergeTransform = require("./other/merge");
27+
const parallelismTransform = require("./other/parallelism");
28+
const recordsInputPathTransform = require("./other/recordsInputPath");
29+
const recordsOutputPathTransform = require("./other/recordsOutputPath");
30+
const recordsPathTransform = require("./other/recordsPath");
2731
const moduleTransform = require("./module/module");
2832
const pluginsTransform = require("./plugins/plugins");
2933
const topScopeTransform = require("./top-scope/top-scope");
@@ -62,7 +66,11 @@ const transformsObject = {
6266
topScopeTransform,
6367
mergeTransform,
6468
devServerTransform,
65-
modeTransform
69+
modeTransform,
70+
parallelismTransform,
71+
recordsInputPathTransform,
72+
recordsOutputPathTransform,
73+
recordsPathTransform
6674
};
6775

6876
module.exports = function runTransform(webpackProperties, action) {

lib/init/transformations/other/__snapshots__/other.test.js.snap

Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,24 @@ exports[`amd transforms correctly using "other-0" data 1`] = `
1616
"
1717
`;
1818

19+
exports[`amd transforms correctly using "other-1" data 1`] = `
20+
"module.exports = {
21+
bail: true,
22+
cache: true,
23+
profile: true,
24+
merge: 'NotMuch',
25+
parallelism: 69,
26+
recordsInputPath: 'somethign',
27+
recordsOutputPath: 'else',
28+
recordsPath: 'Brooklyn',
29+
amd: {
30+
jQuery: false,
31+
kQuery: true
32+
}
33+
};
34+
"
35+
`;
36+
1937
exports[`bail transforms correctly using "other-0" data 1`] = `
2038
"module.exports = {
2139
entry: 'index.js',
@@ -29,6 +47,25 @@ exports[`bail transforms correctly using "other-0" data 1`] = `
2947
"
3048
`;
3149

50+
exports[`bail transforms correctly using "other-1" data 1`] = `
51+
"module.exports = {
52+
bail: false,
53+
cache: true,
54+
profile: true,
55+
merge: 'NotMuch',
56+
parallelism: 69,
57+
recordsInputPath: 'somethign',
58+
recordsOutputPath: 'else',
59+
recordsPath: 'Brooklyn',
60+
amd: {
61+
jQuery: true,
62+
kQuery: false,
63+
bail: false
64+
}
65+
};
66+
"
67+
`;
68+
3269
exports[`cache transforms correctly using "other-0" data 1`] = `
3370
"module.exports = {
3471
entry: 'index.js',
@@ -55,6 +92,44 @@ exports[`cache transforms correctly using "other-0" data 2`] = `
5592
"
5693
`;
5794

95+
exports[`cache transforms correctly using "other-1" data 1`] = `
96+
"module.exports = {
97+
bail: true,
98+
cache: false,
99+
profile: true,
100+
merge: 'NotMuch',
101+
parallelism: 69,
102+
recordsInputPath: 'somethign',
103+
recordsOutputPath: 'else',
104+
recordsPath: 'Brooklyn',
105+
amd: {
106+
jQuery: true,
107+
kQuery: false,
108+
cache: false
109+
}
110+
};
111+
"
112+
`;
113+
114+
exports[`cache transforms correctly using "other-1" data 2`] = `
115+
"module.exports = {
116+
bail: true,
117+
cache: cacheKey,
118+
profile: true,
119+
merge: 'NotMuch',
120+
parallelism: 69,
121+
recordsInputPath: 'somethign',
122+
recordsOutputPath: 'else',
123+
recordsPath: 'Brooklyn',
124+
amd: {
125+
jQuery: true,
126+
kQuery: false,
127+
cache: cacheKey
128+
}
129+
};
130+
"
131+
`;
132+
58133
exports[`merge transforms correctly using "other-0" data 1`] = `
59134
"module.exports = merge(myConfig, {
60135
entry: 'index.js',
@@ -65,6 +140,56 @@ exports[`merge transforms correctly using "other-0" data 1`] = `
65140
"
66141
`;
67142

143+
exports[`merge transforms correctly using "other-1" data 1`] = `
144+
"module.exports = merge(TheirConfig, {
145+
bail: true,
146+
cache: true,
147+
profile: true,
148+
merge: 'NotMuch',
149+
parallelism: 69,
150+
recordsInputPath: 'somethign',
151+
recordsOutputPath: 'else',
152+
recordsPath: 'Brooklyn',
153+
amd: {
154+
jQuery: true,
155+
kQuery: false
156+
}
157+
});
158+
"
159+
`;
160+
161+
exports[`parallelism transforms correctly using "other-0" data 1`] = `
162+
"module.exports = {
163+
entry: 'index.js',
164+
165+
output: {
166+
filename: 'bundle.js'
167+
},
168+
169+
parallelism: 10
170+
}
171+
"
172+
`;
173+
174+
exports[`parallelism transforms correctly using "other-1" data 1`] = `
175+
"module.exports = {
176+
bail: true,
177+
cache: true,
178+
profile: true,
179+
merge: 'NotMuch',
180+
parallelism: 20,
181+
recordsInputPath: 'somethign',
182+
recordsOutputPath: 'else',
183+
recordsPath: 'Brooklyn',
184+
amd: {
185+
jQuery: true,
186+
kQuery: false,
187+
parallelism: 20
188+
}
189+
};
190+
"
191+
`;
192+
68193
exports[`profile transforms correctly using "other-0" data 1`] = `
69194
"module.exports = {
70195
entry: 'index.js',
@@ -77,3 +202,115 @@ exports[`profile transforms correctly using "other-0" data 1`] = `
77202
}
78203
"
79204
`;
205+
206+
exports[`profile transforms correctly using "other-1" data 1`] = `
207+
"module.exports = {
208+
bail: true,
209+
cache: true,
210+
profile: false,
211+
merge: 'NotMuch',
212+
parallelism: 69,
213+
recordsInputPath: 'somethign',
214+
recordsOutputPath: 'else',
215+
recordsPath: 'Brooklyn',
216+
amd: {
217+
jQuery: true,
218+
kQuery: false,
219+
profile: false
220+
}
221+
};
222+
"
223+
`;
224+
225+
exports[`recordsInputPath transforms correctly using "other-0" data 1`] = `
226+
"module.exports = {
227+
entry: 'index.js',
228+
229+
output: {
230+
filename: 'bundle.js'
231+
},
232+
233+
recordsInputPath: path.join('dist', mine)
234+
}
235+
"
236+
`;
237+
238+
exports[`recordsInputPath transforms correctly using "other-1" data 1`] = `
239+
"module.exports = {
240+
bail: true,
241+
cache: true,
242+
profile: true,
243+
merge: 'NotMuch',
244+
parallelism: 69,
245+
recordsInputPath: path.join('dist', ours),
246+
recordsOutputPath: 'else',
247+
recordsPath: 'Brooklyn',
248+
amd: {
249+
jQuery: true,
250+
kQuery: false
251+
}
252+
};
253+
"
254+
`;
255+
256+
exports[`recordsOutputPath transforms correctly using "other-0" data 1`] = `
257+
"module.exports = {
258+
entry: 'index.js',
259+
260+
output: {
261+
filename: 'bundle.js'
262+
},
263+
264+
recordsOutputPath: path.join('src', yours)
265+
}
266+
"
267+
`;
268+
269+
exports[`recordsOutputPath transforms correctly using "other-1" data 1`] = `
270+
"module.exports = {
271+
bail: true,
272+
cache: true,
273+
profile: true,
274+
merge: 'NotMuch',
275+
parallelism: 69,
276+
recordsInputPath: 'somethign',
277+
recordsOutputPath: path.join('src', theirs),
278+
recordsPath: 'Brooklyn',
279+
amd: {
280+
jQuery: true,
281+
kQuery: false
282+
}
283+
};
284+
"
285+
`;
286+
287+
exports[`recordsPath transforms correctly using "other-0" data 1`] = `
288+
"module.exports = {
289+
entry: 'index.js',
290+
291+
output: {
292+
filename: 'bundle.js'
293+
},
294+
295+
recordsPath: path.join(__dirname, 'records.json')
296+
}
297+
"
298+
`;
299+
300+
exports[`recordsPath transforms correctly using "other-1" data 1`] = `
301+
"module.exports = {
302+
bail: true,
303+
cache: true,
304+
profile: true,
305+
merge: 'NotMuch',
306+
parallelism: 69,
307+
recordsInputPath: 'somethign',
308+
recordsOutputPath: 'else',
309+
recordsPath: path.resolve(__dirname, 'gradle.json'),
310+
amd: {
311+
jQuery: true,
312+
kQuery: false
313+
}
314+
};
315+
"
316+
`;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
bail: true,
3+
cache: true,
4+
profile: true,
5+
merge: 'NotMuch',
6+
parallelism: 69,
7+
recordsInputPath: 'somethign',
8+
recordsOutputPath: 'else',
9+
recordsPath: 'Brooklyn',
10+
amd: {
11+
jQuery: true,
12+
kQuery: false
13+
}
14+
};

0 commit comments

Comments
 (0)