electron/spec/api-app-spec.coffee

56 lines
1.7 KiB
CoffeeScript
Raw Normal View History

assert = require 'assert'
remote = require 'remote'
app = remote.require 'app'
BrowserWindow = remote.require 'browser-window'
describe 'app module', ->
describe 'app.getVersion()', ->
it 'returns the version field of package.json', ->
assert.equal app.getVersion(), '0.1.0'
describe 'app.setVersion(version)', ->
it 'overrides the version', ->
assert.equal app.getVersion(), '0.1.0'
app.setVersion 'test-version'
assert.equal app.getVersion(), 'test-version'
app.setVersion '0.1.0'
describe 'app.getName()', ->
it 'returns the name field of package.json', ->
2015-04-14 07:59:45 +00:00
assert.equal app.getName(), 'Electron Test'
describe 'app.setName(name)', ->
it 'overrides the name', ->
2015-04-14 07:59:45 +00:00
assert.equal app.getName(), 'Electron Test'
app.setName 'test-name'
assert.equal app.getName(), 'test-name'
2015-04-21 10:55:44 +00:00
app.setName 'Electron Test'
2015-09-14 09:02:45 +00:00
describe 'BrowserWindow events', ->
w = null
afterEach ->
w.destroy() if w?
w = null
2015-09-14 09:02:45 +00:00
it 'should emit browser-window-focus event when window is focused', (done) ->
app.once 'browser-window-focus', (e, window) ->
assert.equal w.id, window.id
2015-09-14 09:02:45 +00:00
done()
w = new BrowserWindow(show: false)
w.emit 'focus'
2015-09-14 09:02:45 +00:00
it 'should emit browser-window-blur event when window is blured', (done) ->
app.once 'browser-window-blur', (e, window) ->
assert.equal w.id, window.id
done()
w = new BrowserWindow(show: false)
w.emit 'blur'
it 'should emit browser-window-created event when window is created', (done) ->
app.once 'browser-window-created', (e, window) ->
setImmediate ->
assert.equal w.id, window.id
done()
w = new BrowserWindow(show: false)
w.emit 'blur'