|
@@ -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'
|