]> khamidou — GitHub mirrors - electron.git/commitdiff
spec: Make the "remote listeners" test more reliable
authorCheng Zhao <zcbenz@gmail.com>
Mon, 7 Dec 2015 13:28:58 +0000 (21:28 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 7 Dec 2015 13:28:58 +0000 (21:28 +0800)
spec/api-ipc-spec.coffee

index a8d2a65cdef75a3967fb1386e3ba6d162eeb56a6..1aa715c9f759de629cbebb8dc1957132f15c0324 100644 (file)
@@ -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