@@ -71,7 +71,7 @@ console.log = jest.fn()
71
71
beforeEach ( ( ) => {
72
72
jest . clearAllMocks ( )
73
73
} )
74
- chokidar . watch . mockImplementation ( file => {
74
+ chokidar . watch . mockImplementation ( ( file ) => {
75
75
return {
76
76
on : ( type , cb ) => { }
77
77
}
@@ -84,14 +84,14 @@ const runCommand = async (command, options = {}, args = {}, rawArgs = []) => {
84
84
if ( ! args . _ ) args . _ = [ ]
85
85
const commands = { }
86
86
const api = {
87
- // Make app think typescript plugin is installed
87
+ // Make app think typescript plugin is installed
88
88
hasPlugin : jest . fn ( ) . mockReturnValue ( true ) ,
89
89
registerCommand : jest . fn ( ) . mockImplementation ( ( name , options , command ) => {
90
90
// Save registered commands
91
91
commands [ name ] = command
92
92
} ) ,
93
93
// So we can ensure that files were resolved properly
94
- resolve : jest . fn ( path => 'projectPath/' + path ) ,
94
+ resolve : jest . fn ( ( path ) => 'projectPath/' + path ) ,
95
95
chainWebpack : jest . fn ( ) ,
96
96
service : {
97
97
// Mock api.service.run('build/serve')
@@ -120,13 +120,13 @@ describe('electron:build', () => {
120
120
} )
121
121
122
122
const mainConfig = webpack . mock . calls [ 0 ] [ 0 ]
123
- // Typescript rule is not added
123
+ // Typescript rule is not added
124
124
expect ( Object . keys ( mainConfig ) ) . not . toContain ( 'module' )
125
- // Ts files are not resolved
125
+ // Ts files are not resolved
126
126
expect (
127
127
mainConfig . resolve . extensions ? mainConfig . resolve . extensions : [ ]
128
128
) . not . toContain ( 'ts' )
129
- // Proper entry file is used
129
+ // Proper entry file is used
130
130
expect ( mainConfig . entry . background [ 0 ] ) . toBe ( 'projectPath/src/background.js' )
131
131
} )
132
132
@@ -140,7 +140,7 @@ describe('electron:build', () => {
140
140
} )
141
141
142
142
const mainConfig = webpack . mock . calls [ 0 ] [ 0 ]
143
- // Proper entry file is used
143
+ // Proper entry file is used
144
144
expect ( mainConfig . entry . background [ 0 ] ) . toBe (
145
145
'projectPath/customBackground.js'
146
146
)
@@ -156,11 +156,11 @@ describe('electron:build', () => {
156
156
} )
157
157
158
158
const mainConfig = webpack . mock . calls [ 0 ] [ 0 ]
159
- // Main config output is correct
159
+ // Main config output is correct
160
160
expect ( mainConfig . output . path ) . toBe ( 'projectPath/output/bundled' )
161
161
// cli-service build output is correct
162
162
expect ( serviceRun . mock . calls [ 0 ] [ 1 ] . dest ) . toBe ( `output${ path . sep } bundled` )
163
- // Electron-builder output is correct
163
+ // Electron-builder output is correct
164
164
expect ( builder . build . mock . calls [ 0 ] [ 0 ] . config . directories . output ) . toBe (
165
165
'output'
166
166
)
@@ -170,11 +170,11 @@ describe('electron:build', () => {
170
170
await runCommand ( 'electron:build' , { } , { dest : 'output' } )
171
171
172
172
const mainConfig = webpack . mock . calls [ 0 ] [ 0 ]
173
- // Main config output is correct
173
+ // Main config output is correct
174
174
expect ( mainConfig . output . path ) . toBe ( 'projectPath/output/bundled' )
175
175
// cli-service build output is correct
176
176
expect ( serviceRun . mock . calls [ 0 ] [ 1 ] . dest ) . toBe ( `output${ path . sep } bundled` )
177
- // Electron-builder output is correct
177
+ // Electron-builder output is correct
178
178
expect ( builder . build . mock . calls [ 0 ] [ 0 ] . config . directories . output ) . toBe (
179
179
'output'
180
180
)
@@ -184,7 +184,7 @@ describe('electron:build', () => {
184
184
await runCommand ( 'electron:build' , {
185
185
pluginOptions : {
186
186
electronBuilder : {
187
- chainWebpackMainProcess : config => {
187
+ chainWebpackMainProcess : ( config ) => {
188
188
config . node . set ( 'shouldBe' , 'expected' )
189
189
return config
190
190
}
@@ -269,7 +269,7 @@ describe('electron:build', () => {
269
269
270
270
test . each ( [ 'report' , 'report-json' ] ) (
271
271
'--%s arg is passed to renderer build' ,
272
- async argName => {
272
+ async ( argName ) => {
273
273
const args = { }
274
274
args [ argName ] = true
275
275
await runCommand ( 'electron:build' , { } , args )
@@ -339,7 +339,7 @@ describe('electron:build', () => {
339
339
340
340
test . each ( [ 'string config' , 'object config' ] ) (
341
341
'Adds mock legacy assets file for each page (%s)' ,
342
- async configType => {
342
+ async ( configType ) => {
343
343
const stringConfig = configType === 'string config'
344
344
await runCommand ( 'electron:build' , {
345
345
pages : {
@@ -408,7 +408,9 @@ describe('electron:build', () => {
408
408
expect ( webpack ) . toBeCalledTimes ( 2 )
409
409
const preloadWebpackCall = webpack . mock . calls [ 1 ] [ 0 ]
410
410
expect ( preloadWebpackCall . target ) . toBe ( 'electron-preload' )
411
- expect ( preloadWebpackCall . entry ) . toEqual ( { preload : [ 'projectPath/preloadFile' ] } )
411
+ expect ( preloadWebpackCall . entry ) . toEqual ( {
412
+ preload : [ 'projectPath/preloadFile' ]
413
+ } )
412
414
// Make sure preload bundle has been run
413
415
expect ( mockRun ) . toHaveBeenCalledTimes ( 2 )
414
416
webpack . mockClear ( )
@@ -454,13 +456,13 @@ describe('electron:serve', () => {
454
456
} )
455
457
456
458
const mainConfig = webpack . mock . calls [ 0 ] [ 0 ]
457
- // Typescript rule is not added
459
+ // Typescript rule is not added
458
460
expect ( Object . keys ( mainConfig ) ) . not . toContain ( 'module' )
459
- // Ts files are not resolved
461
+ // Ts files are not resolved
460
462
expect (
461
463
mainConfig . resolve . extensions ? mainConfig . resolve . extensions : [ ]
462
464
) . not . toContain ( 'ts' )
463
- // Proper entry file is used
465
+ // Proper entry file is used
464
466
expect ( mainConfig . entry . index [ 0 ] ) . toBe ( 'projectPath/src/background.js' )
465
467
} )
466
468
@@ -474,7 +476,7 @@ describe('electron:serve', () => {
474
476
} )
475
477
476
478
const mainConfig = webpack . mock . calls [ 0 ] [ 0 ]
477
- // Proper entry file is used
479
+ // Proper entry file is used
478
480
expect ( mainConfig . entry . index [ 0 ] ) . toBe ( 'projectPath/customBackground.js' )
479
481
} )
480
482
@@ -488,15 +490,15 @@ describe('electron:serve', () => {
488
490
} )
489
491
490
492
const mainConfig = webpack . mock . calls [ 0 ] [ 0 ]
491
- // Main config output is correct
493
+ // Main config output is correct
492
494
expect ( mainConfig . output . path ) . toBe ( 'projectPath/output' )
493
495
} )
494
496
495
497
test ( 'Custom main process webpack config is used if provided' , async ( ) => {
496
498
await runCommand ( 'electron:serve' , {
497
499
pluginOptions : {
498
500
electronBuilder : {
499
- chainWebpackMainProcess : config => {
501
+ chainWebpackMainProcess : ( config ) => {
500
502
config . node . set ( 'shouldBe' , 'expected' )
501
503
return config
502
504
}
@@ -565,7 +567,7 @@ describe('electron:serve', () => {
565
567
// UglifyJS plugin does not exist
566
568
expect (
567
569
mainConfig . plugins . find (
568
- p => p . __pluginConstructorName === 'UglifyJsPlugin'
570
+ ( p ) => p . __pluginConstructorName === 'UglifyJsPlugin'
569
571
)
570
572
) . toBeUndefined ( )
571
573
// Source maps are enabled
@@ -604,7 +606,9 @@ describe('electron:serve', () => {
604
606
} )
605
607
606
608
// Proper file is watched
607
- expect ( chokidar . watch . mock . calls [ 0 ] [ 0 ] ) . toEqual ( [ 'projectPath/customBackground' ] )
609
+ expect ( chokidar . watch . mock . calls [ 0 ] [ 0 ] ) . toEqual ( [
610
+ 'projectPath/customBackground'
611
+ ] )
608
612
// Child has not yet been killed or unwatched
609
613
expect ( mockExeca . send ) . not . toBeCalled ( )
610
614
expect ( mockExeca . kill ) . not . toBeCalled ( )
@@ -643,10 +647,10 @@ describe('electron:serve', () => {
643
647
// So we can make sure it wasn't called
644
648
jest . spyOn ( process , 'exit' )
645
649
const watchCb = { }
646
- chokidar . watch . mockImplementation ( files => {
650
+ chokidar . watch . mockImplementation ( ( files ) => {
647
651
return {
648
652
on : ( type , cb ) => {
649
- files . forEach ( file => {
653
+ files . forEach ( ( file ) => {
650
654
// Set callback to be called later
651
655
watchCb [ file ] = cb
652
656
} )
@@ -665,7 +669,10 @@ describe('electron:serve', () => {
665
669
} )
666
670
667
671
// Proper file is watched
668
- expect ( chokidar . watch . mock . calls [ 0 ] [ 0 ] ) . toEqual ( [ 'projectPath/customBackground' , 'projectPath/listFile' ] )
672
+ expect ( chokidar . watch . mock . calls [ 0 ] [ 0 ] ) . toEqual ( [
673
+ 'projectPath/customBackground' ,
674
+ 'projectPath/listFile'
675
+ ] )
669
676
// Child has not yet been killed or unwatched
670
677
expect ( mockExeca . send ) . not . toBeCalled ( )
671
678
expect ( mockExeca . kill ) . not . toBeCalled ( )
@@ -864,7 +871,9 @@ describe('electron:serve', () => {
864
871
expect ( webpack ) . toBeCalledTimes ( 2 )
865
872
const preloadWebpackCall = webpack . mock . calls [ 1 ] [ 0 ]
866
873
expect ( preloadWebpackCall . target ) . toBe ( 'electron-preload' )
867
- expect ( preloadWebpackCall . entry ) . toEqual ( { preload : [ 'projectPath/preloadFile' ] } )
874
+ expect ( preloadWebpackCall . entry ) . toEqual ( {
875
+ preload : [ 'projectPath/preloadFile' ]
876
+ } )
868
877
// Make sure preload bundle has been run
869
878
expect ( mockRun ) . toHaveBeenCalledTimes ( 2 )
870
879
webpack . mockClear ( )
0 commit comments