Add spec for exit code on event

This commit is contained in:
Kevin Sawicki 2015-12-07 17:05:08 -08:00
parent 63c0095efb
commit aa82eddca8
3 changed files with 32 additions and 0 deletions

View file

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