From: Cheng Zhao Date: Mon, 7 Dec 2015 13:28:58 +0000 (+0800) Subject: spec: Make the "remote listeners" test more reliable X-Git-Tag: v0.36.0~30^2~6 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=27dd233820ccc7b8e1cd4a56982c9d31f3f4cd13;p=electron.git spec: Make the "remote listeners" test more reliable --- diff --git a/spec/api-ipc-spec.coffee b/spec/api-ipc-spec.coffee index a8d2a65c..1aa715c9 100644 --- a/spec/api-ipc-spec.coffee +++ b/spec/api-ipc-spec.coffee @@ -89,14 +89,14 @@ describe 'ipc module', -> w.loadURL 'file://' + path.join(fixtures, 'api', 'send-sync-message.html') describe 'remote listeners', -> + w = null + afterEach -> + w.destroy() + it 'can be added and removed correctly', -> - count = 0 w = new BrowserWindow(show: false) - listener = () -> - count += 1 - w.removeListener 'blur', listener - w.on 'blur', listener - w.emit 'blur' - w.emit 'blur' - assert.equal count, 1 - w.destroy() + listener = -> + w.on 'test', listener + assert.equal w.listenerCount('test'), 1 + w.removeListener 'test', listener + assert.equal w.listenerCount('test'), 0