spec: Add test case for app.makeSingleInstance
This commit is contained in:
parent
b7119b5756
commit
b4075bed87
3 changed files with 40 additions and 0 deletions
|
@ -157,6 +157,28 @@ describe('app module', function () {
|
|||
})
|
||||
})
|
||||
|
||||
describe('app.makeSingleInstance', function () {
|
||||
it('prevents the second launch of app', function (done) {
|
||||
this.timeout(120000)
|
||||
const appPath = path.join(__dirname, 'fixtures', 'api', 'singleton')
|
||||
// First launch should exit with 0.
|
||||
let secondLaunched = false
|
||||
const first = ChildProcess.spawn(remote.process.execPath, [appPath])
|
||||
first.once('exit', (code) => {
|
||||
assert.ok(secondLaunched)
|
||||
assert.equal(code, 0)
|
||||
done()
|
||||
})
|
||||
// Second launch should exit with 1.
|
||||
const second = ChildProcess.spawn(remote.process.execPath, [appPath])
|
||||
second.once('exit', (code) => {
|
||||
assert.ok(!secondLaunched)
|
||||
assert.equal(code, 1)
|
||||
secondLaunched = true
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('app.relaunch', function () {
|
||||
let server = null
|
||||
const socketPath = process.platform === 'win32' ? '\\\\.\\pipe\\electron-app-relaunch' : '/tmp/electron-app-relaunch'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue