Skip to content

Commit 54e7dba

Browse files
committed
Added test that asserts userPath is same as hardcoded path
1 parent b061f6e commit 54e7dba

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

tests/index.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,24 @@ describe('demo app', function () {
1717

1818
let app
1919

20-
const removeStoredPreferences = function () {
20+
const getUserDataPath = function () {
2121
const productName = require('../package').productName
22-
23-
let userDataPath = ''
2422
switch (process.platform) {
2523
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)
2825
case 'win32':
29-
userDataPath = path.join(process.env.APPDATA, productName)
30-
break
26+
return path.join(process.env.APPDATA, productName)
3127
case 'freebsd':
3228
case 'linux':
3329
case 'sunos':
34-
userDataPath = path.join(process.env.HOME, '.config', productName)
35-
break
30+
return path.join(process.env.HOME, '.config', productName)
3631
default:
3732
throw new Error(`Unknown userDataPath path for platform ${process.platform}`)
3833
}
34+
}
3935

36+
const removeStoredPreferences = function () {
37+
const userDataPath = getUserDataPath()
4038
try {
4139
fs.unlinkSync(path.join(userDataPath, 'activeDemoButtonId.json'))
4240
} catch (error) {
@@ -123,6 +121,14 @@ describe('demo app', function () {
123121
}
124122
})
125123

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+
126132
it('opens a window displaying the about page', function () {
127133
return app.client.getWindowCount().should.eventually.equal(1)
128134
.browserWindow.isMinimized().should.eventually.be.false

0 commit comments

Comments
 (0)