/
applyCLIPlugin.test.js
51 lines (48 loc) · 1.88 KB
/
applyCLIPlugin.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const webpackCLI = require('../lib/webpack-cli');
const CLIPlugin = require('../lib/plugins/CLIPlugin');
const applyCLIPlugin = new webpackCLI().applyCLIPlugin;
describe('CLIPluginResolver', () => {
it('should add CLI plugin to single compiler object', async () => {
const result = await applyCLIPlugin({ options: {}, path: new WeakMap() }, { hot: true, prefetch: true });
expect(result.options.plugins[0] instanceof CLIPlugin).toBeTruthy();
expect(result.options.plugins[0].options).toEqual({
configPath: undefined,
helpfulOutput: true,
hot: true,
progress: undefined,
prefetch: true,
analyze: undefined,
});
});
it('should add CLI plugin to multi compiler object', async () => {
const result = await applyCLIPlugin({ options: [{}, {}], path: new WeakMap() }, { hot: true, prefetch: true });
expect(result.options[0].plugins[0] instanceof CLIPlugin).toBeTruthy();
expect(result.options[1].plugins[0] instanceof CLIPlugin).toBeTruthy();
expect(result.options).toEqual([
{
plugins: [
new CLIPlugin({
configPath: undefined,
helpfulOutput: true,
hot: true,
progress: undefined,
prefetch: true,
analyze: undefined,
}),
],
},
{
plugins: [
new CLIPlugin({
configPath: undefined,
helpfulOutput: true,
hot: true,
progress: undefined,
prefetch: true,
analyze: undefined,
}),
],
},
]);
});
});