@@ -2,24 +2,24 @@ const { resolve } = require('path');
2
2
const webpackCLI = require ( '../lib/webpack-cli' ) ;
3
3
4
4
const targetValues = [ 'web' , 'webworker' , 'node' , 'async-node' , 'node-webkit' , 'electron-main' , 'electron-renderer' , 'electron-preload' ] ;
5
- const applyOptions = new webpackCLI ( ) . applyOptions ;
5
+ const cli = new webpackCLI ( ) ;
6
6
7
7
describe ( 'BasicResolver' , ( ) => {
8
8
it ( 'should handle the output option' , async ( ) => {
9
- const result = await applyOptions ( { options : { } } , { outputPath : './bundle' } ) ;
9
+ const result = await cli . applyOptions ( { options : { } } , { outputPath : './bundle' } ) ;
10
10
11
11
expect ( result . options . output . path ) . toEqual ( resolve ( 'bundle' ) ) ;
12
12
} ) ;
13
13
14
14
it ( 'should handle the mode option [production]' , async ( ) => {
15
- const result = await applyOptions ( { options : { } } , { mode : 'production' } ) ;
15
+ const result = await cli . applyOptions ( { options : { } } , { mode : 'production' } ) ;
16
16
17
17
expect ( result . options ) . toMatchObject ( { mode : 'production' } ) ;
18
18
expect ( result . options . mode ) . toEqual ( 'production' ) ;
19
19
} ) ;
20
20
21
21
it ( 'should handle the mode option [development]' , async ( ) => {
22
- const result = await applyOptions (
22
+ const result = await cli . applyOptions (
23
23
{ options : { } } ,
24
24
{
25
25
mode : 'development' ,
@@ -31,7 +31,7 @@ describe('BasicResolver', () => {
31
31
} ) ;
32
32
33
33
it ( 'should handle the mode option [none]' , async ( ) => {
34
- const result = await applyOptions (
34
+ const result = await cli . applyOptions (
35
35
{ options : { } } ,
36
36
{
37
37
mode : 'none' ,
@@ -44,34 +44,34 @@ describe('BasicResolver', () => {
44
44
45
45
it ( 'should prefer supplied move flag over NODE_ENV' , async ( ) => {
46
46
process . env . NODE_ENV = 'production' ;
47
- const result = await applyOptions ( { options : { } } , { mode : 'development' } ) ;
47
+ const result = await cli . applyOptions ( { options : { } } , { mode : 'development' } ) ;
48
48
49
49
expect ( result . options ) . toMatchObject ( { mode : 'development' } ) ;
50
50
} ) ;
51
51
52
52
it ( 'should prefer supplied move flag over mode from config' , async ( ) => {
53
- const result = await applyOptions ( { options : { mode : 'development' } } , { mode : 'production' } ) ;
53
+ const result = await cli . applyOptions ( { options : { mode : 'development' } } , { mode : 'production' } ) ;
54
54
55
55
expect ( result . options ) . toMatchObject ( { mode : 'production' } ) ;
56
56
} ) ;
57
57
58
58
it ( 'should prefer mode form config over NODE_ENV' , async ( ) => {
59
59
process . env . NODE_ENV = 'development' ;
60
- const result = await applyOptions ( { options : { } } , { mode : 'production' } ) ;
60
+ const result = await cli . applyOptions ( { options : { } } , { mode : 'production' } ) ;
61
61
62
62
expect ( result . options ) . toMatchObject ( { mode : 'production' } ) ;
63
63
} ) ;
64
64
65
65
it ( 'should prefer mode form flag over NODE_ENV and config' , async ( ) => {
66
66
process . env . NODE_ENV = 'development' ;
67
- const result = await applyOptions ( { options : { } } , { } ) ;
67
+ const result = await cli . applyOptions ( { options : { } } , { } ) ;
68
68
69
69
expect ( result . options ) . toMatchObject ( { mode : 'development' } ) ;
70
70
} ) ;
71
71
72
72
targetValues . map ( ( option ) => {
73
73
it ( `should handle ${ option } option` , async ( ) => {
74
- const result = await applyOptions ( { options : { } } , { target : option } ) ;
74
+ const result = await cli . applyOptions ( { options : { } } , { target : option } ) ;
75
75
76
76
expect ( result . options . target ) . toEqual ( option ) ;
77
77
} ) ;
0 commit comments