@@ -33,13 +33,15 @@ beforeEach(() => {
33
33
// Reset mock status
34
34
jest . clearAllMocks ( )
35
35
} )
36
+ const runGenerator = ( ) =>
37
+ generator ( mockApi , { electronBuilder : { electronVersion : '^5.0.0' } } )
36
38
37
39
describe ( '.gitignore' , ( ) => {
38
40
test ( 'extends gitignore if it exists' , ( ) => {
39
41
// Mock existence of .gitignore
40
42
fs . existsSync = jest . fn ( path => path === 'apiResolve_./.gitignore' )
41
43
// Run the generator with mock api
42
- generator ( mockApi )
44
+ runGenerator ( )
43
45
// Run the onCreateComplete callback
44
46
completionCb ( )
45
47
// New .gitignore should have been written
@@ -53,7 +55,7 @@ describe('.gitignore', () => {
53
55
// Mock lack of .gitignore
54
56
fs . existsSync = jest . fn ( path => ! ( path === 'apiResolve_./.gitignore' ) )
55
57
// Run the generator with mock api
56
- generator ( mockApi )
58
+ runGenerator ( )
57
59
// Run the onCreateComplete callback
58
60
completionCb ( )
59
61
// New .gitignore should not have been read from or written
@@ -88,7 +90,7 @@ describe('.gitignore', () => {
88
90
// Mock existence of .gitignore
89
91
fs . existsSync = jest . fn ( path => path === 'apiResolve_./.gitignore' )
90
92
// Run the generator with mock api
91
- generator ( mockApi )
93
+ runGenerator ( )
92
94
// Run the onCreateComplete callback
93
95
completionCb ( )
94
96
// New .gitignore should not have been written
@@ -113,7 +115,7 @@ describe('background.js', () => {
113
115
)
114
116
// Mock existence of background file
115
117
fs . existsSync . mockImplementation ( path => path === `apiResolve_./${ file } ` )
116
- generator ( mockApi )
118
+ runGenerator ( )
117
119
completionCb ( )
118
120
expect ( mockApi . render ) . not . toBeCalled ( )
119
121
}
@@ -141,7 +143,7 @@ describe('background.js', () => {
141
143
// return mock content
142
144
return background
143
145
} )
144
- generator ( mockApi )
146
+ runGenerator ( )
145
147
completionCb ( )
146
148
expect ( fs . writeFileSync ) . toBeCalledWith (
147
149
'apiResolve_./src/background.ts' ,
@@ -152,7 +154,7 @@ describe('background.js', () => {
152
154
153
155
describe . each ( [ 'postinstall' , 'postuninstall' ] ) ( 'package.json (%s)' , script => {
154
156
test ( `Adds electron-builder install-app-deps to ${ script } ` , ( ) => {
155
- generator ( mockApi )
157
+ runGenerator ( )
156
158
completionCb ( )
157
159
expect ( pkg . scripts [ script ] ) . toBe ( 'electron-builder install-app-deps' )
158
160
} )
@@ -169,7 +171,7 @@ describe.each(['postinstall', 'postuninstall'])('package.json (%s)', script => {
169
171
return 'existing_content'
170
172
} )
171
173
172
- generator ( mockApi )
174
+ runGenerator ( )
173
175
completionCb ( )
174
176
175
177
expect ( pkg . scripts [ script ] ) . toBe (
@@ -193,7 +195,7 @@ describe.each(['postinstall', 'postuninstall'])('package.json (%s)', script => {
193
195
return 'existing_content'
194
196
} )
195
197
196
- generator ( mockApi )
198
+ runGenerator ( )
197
199
completionCb ( )
198
200
199
201
expect ( pkg . scripts [ script ] ) . toBe (
0 commit comments