docs: Make ipcRenderer and ipcMain listener API docs consistent (#44651)
* docs: Make ipcRenderer and ipcMain listener API docs consistent * test: add some unit tests for ipcRenderer/ipcMain listener behavior * fix: Mark on/off methods as primary and addListener/removeListener as aliases * fix: clear all listeners before running ipcMain removeAllListeners tests
This commit is contained in:
parent
aa7a5e6ca9
commit
10d967028a
4 changed files with 86 additions and 10 deletions
|
@ -92,4 +92,27 @@ describe('ipc main module', () => {
|
|||
expect(v).to.equal('hello');
|
||||
});
|
||||
});
|
||||
|
||||
describe('ipcMain.removeAllListeners', () => {
|
||||
beforeEach(() => { ipcMain.removeAllListeners(); });
|
||||
beforeEach(() => { ipcMain.removeAllListeners(); });
|
||||
|
||||
it('removes only the given channel', () => {
|
||||
ipcMain.on('channel1', () => {});
|
||||
ipcMain.on('channel2', () => {});
|
||||
|
||||
ipcMain.removeAllListeners('channel1');
|
||||
|
||||
expect(ipcMain.eventNames()).to.deep.equal(['channel2']);
|
||||
});
|
||||
|
||||
it('removes all channels if no channel is specified', () => {
|
||||
ipcMain.on('channel1', () => {});
|
||||
ipcMain.on('channel2', () => {});
|
||||
|
||||
ipcMain.removeAllListeners();
|
||||
|
||||
expect(ipcMain.eventNames()).to.deep.equal([]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue