mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Add spec for error on removing all IPC listeners
This commit is contained in:
@@ -495,4 +495,26 @@ describe('ipc module', function () {
|
||||
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)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user