Add spec for error on removing all IPC listeners
This commit is contained in:
parent
c8ff67ab75
commit
b61e1fd69f
1 changed files with 22 additions and 0 deletions
|
@ -495,4 +495,26 @@ describe('ipc module', function () {
|
||||||
assert.equal(w.listenerCount('test'), 0)
|
assert.equal(w.listenerCount('test'), 0)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('throws an error when removing all the listeners', () => {
|
||||||
|
ipcMain.on('test-event', () => {})
|
||||||
|
assert.equal(ipcMain.listenerCount('test-event'), 1)
|
||||||
|
|
||||||
|
ipcRenderer.on('test-event', () => {})
|
||||||
|
assert.equal(ipcRenderer.listenerCount('test-event'), 1)
|
||||||
|
|
||||||
|
assert.throws(() => {
|
||||||
|
ipcMain.removeAllListeners()
|
||||||
|
}, /Removing all listeners from ipcMain will make Electron internals stop working/)
|
||||||
|
|
||||||
|
assert.throws(() => {
|
||||||
|
ipcRenderer.removeAllListeners()
|
||||||
|
}, /Removing all listeners from ipcRenderer will make Electron internals stop working/)
|
||||||
|
|
||||||
|
ipcMain.removeAllListeners('test-event')
|
||||||
|
assert.equal(ipcMain.listenerCount('test-event'), 0)
|
||||||
|
|
||||||
|
ipcRenderer.removeAllListeners('test-event')
|
||||||
|
assert.equal(ipcRenderer.listenerCount('test-event'), 0)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue