Add spec for exit code on event
This commit is contained in:
parent
63c0095efb
commit
aa82eddca8
3 changed files with 32 additions and 0 deletions
|
@ -1,4 +1,6 @@
|
|||
assert = require 'assert'
|
||||
ChildProcess = require 'child_process'
|
||||
path = require 'path'
|
||||
{remote} = require 'electron'
|
||||
{app, BrowserWindow} = remote.require 'electron'
|
||||
|
||||
|
@ -29,6 +31,23 @@ describe 'app module', ->
|
|||
it 'should not be empty', ->
|
||||
assert.notEqual app.getLocale(), ''
|
||||
|
||||
describe 'app.exit(exitCode)', ->
|
||||
appProcess = null
|
||||
afterEach ->
|
||||
appProcess?.kill()
|
||||
|
||||
it 'emits a process exit event with the code', (done) ->
|
||||
appPath = path.join(__dirname, 'fixtures', 'api', 'quit-app')
|
||||
electronPath = remote.getGlobal('process').execPath
|
||||
appProcess = ChildProcess.spawn(electronPath, [appPath])
|
||||
|
||||
output = ''
|
||||
appProcess.stdout.on 'data', (data) -> output += data
|
||||
appProcess.on 'close', (code) ->
|
||||
assert.notEqual output.indexOf('Exit event with code: 123'), -1
|
||||
assert.equal code, 123
|
||||
done()
|
||||
|
||||
describe 'BrowserWindow events', ->
|
||||
w = null
|
||||
afterEach ->
|
||||
|
|
9
spec/fixtures/api/quit-app/main.js
vendored
Normal file
9
spec/fixtures/api/quit-app/main.js
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
var app = require('electron').app
|
||||
|
||||
app.on('ready', function () {
|
||||
app.exit(123)
|
||||
})
|
||||
|
||||
process.on('exit', function (code) {
|
||||
console.log('Exit event with code: ' + code)
|
||||
})
|
4
spec/fixtures/api/quit-app/package.json
vendored
Normal file
4
spec/fixtures/api/quit-app/package.json
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"name": "quit-app",
|
||||
"main": "main.js"
|
||||
}
|
Loading…
Reference in a new issue