@@ -17,26 +17,24 @@ describe('demo app', function () {
17
17
18
18
let app
19
19
20
- const removeStoredPreferences = function ( ) {
20
+ const getUserDataPath = function ( ) {
21
21
const productName = require ( '../package' ) . productName
22
-
23
- let userDataPath = ''
24
22
switch ( process . platform ) {
25
23
case 'darwin' :
26
- userDataPath = path . join ( process . env . HOME , 'Library' , 'Application Support' , productName )
27
- break
24
+ return path . join ( process . env . HOME , 'Library' , 'Application Support' , productName )
28
25
case 'win32' :
29
- userDataPath = path . join ( process . env . APPDATA , productName )
30
- break
26
+ return path . join ( process . env . APPDATA , productName )
31
27
case 'freebsd' :
32
28
case 'linux' :
33
29
case 'sunos' :
34
- userDataPath = path . join ( process . env . HOME , '.config' , productName )
35
- break
30
+ return path . join ( process . env . HOME , '.config' , productName )
36
31
default :
37
32
throw new Error ( `Unknown userDataPath path for platform ${ process . platform } ` )
38
33
}
34
+ }
39
35
36
+ const removeStoredPreferences = function ( ) {
37
+ const userDataPath = getUserDataPath ( )
40
38
try {
41
39
fs . unlinkSync ( path . join ( userDataPath , 'activeDemoButtonId.json' ) )
42
40
} catch ( error ) {
@@ -123,6 +121,14 @@ describe('demo app', function () {
123
121
}
124
122
} )
125
123
124
+ it ( 'checks hardcoded path for userData is correct' , function ( ) {
125
+ return app . client . execute ( function ( ) {
126
+ return require ( 'electron' ) . remote . app . getPath ( 'userData' )
127
+ } ) . then ( function ( result ) {
128
+ return result . value
129
+ } ) . should . eventually . equal ( getUserDataPath ( ) )
130
+ } )
131
+
126
132
it ( 'opens a window displaying the about page' , function ( ) {
127
133
return app . client . getWindowCount ( ) . should . eventually . equal ( 1 )
128
134
. browserWindow . isMinimized ( ) . should . eventually . be . false
0 commit comments