@@ -62,8 +62,8 @@ describe('.gitignore', () => {
62
62
'apiResolve_./.gitignore' ,
63
63
expect . any ( String )
64
64
)
65
- // Only index and background should have been written
66
- expect ( fs . writeFileSync ) . toHaveBeenCalledTimes ( 2 )
65
+ // Only background.js should have been written
66
+ expect ( fs . writeFileSync ) . toHaveBeenCalledTimes ( 1 )
67
67
} )
68
68
69
69
test . each ( [ '#Electron-builder output' , '/dist_electron' ] ) (
@@ -100,13 +100,8 @@ describe('index.html', () => {
100
100
test . each ( [
101
101
// None
102
102
'' ,
103
- // Node_modules path
104
- ` <% if (VUE_APP_NODE_MODULES_PATH !== "false") { %><script>require('module').globalPaths.push('<%= VUE_APP_NODE_MODULES_PATH %>')</script><% } %>\n` ,
105
103
// Base URL
106
- ` <% if (BASE_URL === './') { %><base href="app://./" /><% } %>\n` ,
107
- // Both
108
- ` <% if (BASE_URL === './') { %><base href="app://./" /><% } %>
109
- <% if (VUE_APP_NODE_MODULES_PATH !== "false") { %><script>require('module').globalPaths.push('<%= VUE_APP_NODE_MODULES_PATH %>')</script><% } %>\n`
104
+ ` <% if (BASE_URL === './') { %><base href="app://./" /><% } %>\n`
110
105
] ) ( 'Only add missing tags to index.html' , existing => {
111
106
// Disable .gitignore modification
112
107
fs . existsSync . mockReturnValueOnce ( false )
@@ -117,7 +112,7 @@ describe('index.html', () => {
117
112
return JSON . stringify ( { scripts : { } } )
118
113
}
119
114
// return mock content
120
- return `<head>\n${ existing } </head>`
115
+ return ` <head>\n${ existing } </head>`
121
116
} )
122
117
123
118
// Run the generator with mock api
@@ -126,22 +121,9 @@ describe('index.html', () => {
126
121
completionCb ( )
127
122
128
123
const index = fs . writeFileSync . mock . calls [ 0 ] [ 1 ]
129
- // Opening and closing tags still exist
130
- expect ( index . match ( / ^ \s * ?< h e a d .* ?> \s * ?$ / gm) . length ) . toBe ( 1 )
131
- expect ( index . match ( / ^ \s * ?< \/ h e a d .* ?> \s * ?$ / gm) . length ) . toBe ( 1 )
132
- // Each tag exists once
133
- expect (
134
- index . match (
135
- // Base URL
136
- / < % i f \( B A S E _ U R L = = = ' \. \/ ' \) { % > < b a s e h r e f = " a p p : \/ \/ \. \/ " \/ > < % } % > / g
137
- ) . length
138
- ) . toBe ( 1 )
139
- expect (
140
- index . match (
141
- // Node_modules path
142
- / < % i f \( V U E _ A P P _ N O D E _ M O D U L E S _ P A T H ! = = " f a l s e " \) { % > < s c r i p t > r e q u i r e \( ' m o d u l e ' \) \. g l o b a l P a t h s \. p u s h \( ' < % = V U E _ A P P _ N O D E _ M O D U L E S _ P A T H % > ' \) < \/ s c r i p t > < % } % > / g
143
- ) . length
144
- ) . toBe ( 1 )
124
+ expect ( index ) . toBe ( ` <head>
125
+ <% if (BASE_URL === './') { %><base href="app://./" /><% } %>
126
+ </head>` )
145
127
} )
146
128
} )
147
129
@@ -191,43 +173,6 @@ describe('background.js', () => {
191
173
background
192
174
)
193
175
} )
194
-
195
- test . each ( [ false , true ] ) (
196
- 'Background has node module path added if it does not exist' ,
197
- usesTS => {
198
- const file = `src/background.${ usesTS ? 'ts' : 'js' } `
199
- // Mock having typescript
200
- mockApi . hasPlugin . mockImplementationOnce (
201
- plugin => plugin === 'typescript' && usesTS
202
- )
203
- // Mock not having node path added
204
- fs . readFileSync . mockImplementation ( ( path , encoding ) => {
205
- // Check that utf8 encoding is set
206
- expect ( encoding ) . toBe ( 'utf8' )
207
- if ( path === 'apiResolve_./package.json' ) {
208
- return JSON . stringify ( { scripts : { } } )
209
- }
210
- // return mock content
211
- return `const isDevelopment = process.env.NODE_ENV !== 'production'
212
- existing_content`
213
- } )
214
- // Mock existence of background file
215
- fs . existsSync . mockImplementation ( path => path === `apiResolve_./${ file } ` )
216
- generator ( mockApi )
217
- completionCb ( )
218
- expect ( mockApi . render ) . not . toBeCalled ( )
219
- expect ( fs . writeFileSync ) . toBeCalledWith (
220
- `apiResolve_./${ file } ` ,
221
- `const isDevelopment = process.env.NODE_ENV !== 'production'
222
- if (isDevelopment) {
223
- // Don't load any native (external) modules until the following line is run:
224
- require('module').globalPaths.push(process.env.NODE_MODULES_PATH)
225
- }
226
-
227
- existing_content`
228
- )
229
- }
230
- )
231
176
} )
232
177
233
178
describe ( 'package.json' , ( ) => {
0 commit comments