From ca8943c4ba75b7c4abce1235bb7ddba747409100 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 14 Sep 2015 17:02:45 +0800 Subject: [PATCH] spec: browser-window-created event --- spec/api-app-spec.coffee | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/spec/api-app-spec.coffee b/spec/api-app-spec.coffee index 5c6591cadf50..38ef22ac80bd 100644 --- a/spec/api-app-spec.coffee +++ b/spec/api-app-spec.coffee @@ -26,19 +26,30 @@ describe 'app module', -> assert.equal app.getName(), 'test-name' app.setName 'Electron Test' - describe 'focus/blur event', -> + describe 'BrowserWindow events', -> w = null - beforeEach -> - w.destroy() if w? - w = new BrowserWindow(show: false, width: 400, height: 400) afterEach -> w.destroy() if w? w = null - it 'should emit focus event', (done) -> + + 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 + done() + w = new BrowserWindow(show: false) + w.emit 'focus' + + 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() - app.once 'browser-window-focus', (e, window) -> - assert.equal w.id, window.id - w.emit 'blur' - w.emit 'focus' + 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'