File tree Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change 3
3
*/
4
4
import * as path from 'path' ;
5
5
import * as url from 'url' ;
6
+ import * as nodeEnv from '_utils/node-env' ;
6
7
// eslint-disable-next-line import/no-extraneous-dependencies
7
8
import { BrowserWindow , app } from 'electron' ;
8
9
9
- let mainWindow : Electron . BrowserWindow | null ;
10
+ let mainWindow : Electron . BrowserWindow | null = null ;
10
11
11
12
function createWindow ( ) : void {
12
13
// Create the browser window.
@@ -15,7 +16,7 @@ function createWindow(): void {
15
16
width : 800 ,
16
17
webPreferences : {
17
18
webSecurity : false ,
18
- devTools : process . env . NODE_ENV !== 'production' ,
19
+ devTools : nodeEnv . dev ,
19
20
} ,
20
21
} ) ;
21
22
@@ -61,3 +62,7 @@ app.on('activate', () => {
61
62
62
63
// In this file you can include the rest of your app"s specific main process
63
64
// code. You can also put them in separate files and require them here.
65
+
66
+ // eslint-disable-next-line import/prefer-default-export
67
+ export const exportedForTests = nodeEnv . test
68
+ ? { mainWindow, createWindow } : undefined ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Predefined NODE_ENV values
3
+ */
4
+
5
+ /** `NODE_ENV=production` */
6
+ export const prod = process . env . NODE_ENV === 'production' ;
7
+
8
+ /** `NODE_ENV=development` */
9
+ export const dev = process . env . NODE_ENV === 'development' ;
10
+
11
+ /** `NODE_ENV=test` */
12
+ export const test = process . env . NODE_ENV === 'test' ;
Original file line number Diff line number Diff line change
1
+ import { exportedForTests } from '_main/main' ;
2
+
3
+ jest . mock ( 'electron' , ( ) => ( {
4
+ app : { on : jest . fn ( ) } ,
5
+ } ) ) ;
6
+
7
+ test ( 'Private props exported for unit tests' , ( ) => {
8
+ expect ( exportedForTests ) . toBeDefined ( ) ;
9
+ } ) ;
You can’t perform that action at this time.
0 commit comments