@@ -33,13 +33,15 @@ beforeEach(() => {
3333 // Reset mock status
3434 jest . clearAllMocks ( )
3535} )
36+ const runGenerator = ( ) =>
37+ generator ( mockApi , { electronBuilder : { electronVersion : '^5.0.0' } } )
3638
3739describe ( '.gitignore' , ( ) => {
3840 test ( 'extends gitignore if it exists' , ( ) => {
3941 // Mock existence of .gitignore
4042 fs . existsSync = jest . fn ( path => path === 'apiResolve_./.gitignore' )
4143 // Run the generator with mock api
42- generator ( mockApi )
44+ runGenerator ( )
4345 // Run the onCreateComplete callback
4446 completionCb ( )
4547 // New .gitignore should have been written
@@ -53,7 +55,7 @@ describe('.gitignore', () => {
5355 // Mock lack of .gitignore
5456 fs . existsSync = jest . fn ( path => ! ( path === 'apiResolve_./.gitignore' ) )
5557 // Run the generator with mock api
56- generator ( mockApi )
58+ runGenerator ( )
5759 // Run the onCreateComplete callback
5860 completionCb ( )
5961 // New .gitignore should not have been read from or written
@@ -88,7 +90,7 @@ describe('.gitignore', () => {
8890 // Mock existence of .gitignore
8991 fs . existsSync = jest . fn ( path => path === 'apiResolve_./.gitignore' )
9092 // Run the generator with mock api
91- generator ( mockApi )
93+ runGenerator ( )
9294 // Run the onCreateComplete callback
9395 completionCb ( )
9496 // New .gitignore should not have been written
@@ -113,7 +115,7 @@ describe('background.js', () => {
113115 )
114116 // Mock existence of background file
115117 fs . existsSync . mockImplementation ( path => path === `apiResolve_./${ file } ` )
116- generator ( mockApi )
118+ runGenerator ( )
117119 completionCb ( )
118120 expect ( mockApi . render ) . not . toBeCalled ( )
119121 }
@@ -141,7 +143,7 @@ describe('background.js', () => {
141143 // return mock content
142144 return background
143145 } )
144- generator ( mockApi )
146+ runGenerator ( )
145147 completionCb ( )
146148 expect ( fs . writeFileSync ) . toBeCalledWith (
147149 'apiResolve_./src/background.ts' ,
@@ -152,7 +154,7 @@ describe('background.js', () => {
152154
153155describe . each ( [ 'postinstall' , 'postuninstall' ] ) ( 'package.json (%s)' , script => {
154156 test ( `Adds electron-builder install-app-deps to ${ script } ` , ( ) => {
155- generator ( mockApi )
157+ runGenerator ( )
156158 completionCb ( )
157159 expect ( pkg . scripts [ script ] ) . toBe ( 'electron-builder install-app-deps' )
158160 } )
@@ -169,7 +171,7 @@ describe.each(['postinstall', 'postuninstall'])('package.json (%s)', script => {
169171 return 'existing_content'
170172 } )
171173
172- generator ( mockApi )
174+ runGenerator ( )
173175 completionCb ( )
174176
175177 expect ( pkg . scripts [ script ] ) . toBe (
@@ -193,7 +195,7 @@ describe.each(['postinstall', 'postuninstall'])('package.json (%s)', script => {
193195 return 'existing_content'
194196 } )
195197
196- generator ( mockApi )
198+ runGenerator ( )
197199 completionCb ( )
198200
199201 expect ( pkg . scripts [ script ] ) . toBe (
0 commit comments