Remove any existing IPC hanlders/listeners before assigning new ones inside the downloadsManager (#2493)
* Remove any existing IPC hanlders/listeners before assigning new ones inside the downloadsManager * Mock more ipx functions during tests
This commit is contained in:
@@ -50,6 +50,8 @@ jest.mock('electron', () => ({
|
|||||||
on: jest.fn(),
|
on: jest.fn(),
|
||||||
handle: jest.fn(),
|
handle: jest.fn(),
|
||||||
emit: jest.fn(),
|
emit: jest.fn(),
|
||||||
|
removeHandler: jest.fn(),
|
||||||
|
removeListener: jest.fn(),
|
||||||
},
|
},
|
||||||
screen: {
|
screen: {
|
||||||
on: jest.fn(),
|
on: jest.fn(),
|
||||||
|
@@ -40,6 +40,8 @@ jest.mock('electron', () => {
|
|||||||
emit: jest.fn(),
|
emit: jest.fn(),
|
||||||
handle: jest.fn(),
|
handle: jest.fn(),
|
||||||
on: jest.fn(),
|
on: jest.fn(),
|
||||||
|
removeHandler: jest.fn(),
|
||||||
|
removeListener: jest.fn(),
|
||||||
},
|
},
|
||||||
Menu: {
|
Menu: {
|
||||||
getApplicationMenu: () => ({
|
getApplicationMenu: () => ({
|
||||||
|
@@ -77,9 +77,21 @@ export class DownloadsManager extends JsonFileManager<DownloadedItems> {
|
|||||||
this.checkForDeletedFiles();
|
this.checkForDeletedFiles();
|
||||||
this.reloadFilesForMAS();
|
this.reloadFilesForMAS();
|
||||||
|
|
||||||
|
this.loadIPCHandlers();
|
||||||
|
};
|
||||||
|
|
||||||
|
private loadIPCHandlers = () => {
|
||||||
|
ipcMain.removeHandler(REQUEST_HAS_DOWNLOADS);
|
||||||
ipcMain.handle(REQUEST_HAS_DOWNLOADS, () => {
|
ipcMain.handle(REQUEST_HAS_DOWNLOADS, () => {
|
||||||
return this.hasDownloads();
|
return this.hasDownloads();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcMain.removeListener(DOWNLOADS_DROPDOWN_FOCUSED, this.clearAutoCloseTimeout);
|
||||||
|
ipcMain.removeListener(UPDATE_AVAILABLE, this.onUpdateAvailable);
|
||||||
|
ipcMain.removeListener(UPDATE_DOWNLOADED, this.onUpdateDownloaded);
|
||||||
|
ipcMain.removeListener(UPDATE_PROGRESS, this.onUpdateProgress);
|
||||||
|
ipcMain.removeListener(NO_UPDATE_AVAILABLE, this.noUpdateAvailable);
|
||||||
|
|
||||||
ipcMain.on(DOWNLOADS_DROPDOWN_FOCUSED, this.clearAutoCloseTimeout);
|
ipcMain.on(DOWNLOADS_DROPDOWN_FOCUSED, this.clearAutoCloseTimeout);
|
||||||
ipcMain.on(UPDATE_AVAILABLE, this.onUpdateAvailable);
|
ipcMain.on(UPDATE_AVAILABLE, this.onUpdateAvailable);
|
||||||
ipcMain.on(UPDATE_DOWNLOADED, this.onUpdateDownloaded);
|
ipcMain.on(UPDATE_DOWNLOADED, this.onUpdateDownloaded);
|
||||||
|
@@ -32,6 +32,8 @@ jest.mock('electron', () => {
|
|||||||
emit: jest.fn(),
|
emit: jest.fn(),
|
||||||
handle: jest.fn(),
|
handle: jest.fn(),
|
||||||
on: jest.fn(),
|
on: jest.fn(),
|
||||||
|
removeHandler: jest.fn(),
|
||||||
|
removeListener: jest.fn(),
|
||||||
},
|
},
|
||||||
Notification: NotificationMock,
|
Notification: NotificationMock,
|
||||||
};
|
};
|
||||||
|
@@ -41,6 +41,8 @@ jest.mock('electron', () => {
|
|||||||
emit: jest.fn(),
|
emit: jest.fn(),
|
||||||
handle: jest.fn(),
|
handle: jest.fn(),
|
||||||
on: jest.fn(),
|
on: jest.fn(),
|
||||||
|
removeHandler: jest.fn(),
|
||||||
|
removeListener: jest.fn(),
|
||||||
},
|
},
|
||||||
Notification: NotificationMock,
|
Notification: NotificationMock,
|
||||||
};
|
};
|
||||||
|
@@ -53,6 +53,8 @@ jest.mock('electron', () => {
|
|||||||
emit: jest.fn(),
|
emit: jest.fn(),
|
||||||
handle: jest.fn(),
|
handle: jest.fn(),
|
||||||
on: jest.fn(),
|
on: jest.fn(),
|
||||||
|
removeHandler: jest.fn(),
|
||||||
|
removeListener: jest.fn(),
|
||||||
},
|
},
|
||||||
Notification: NotificationMock,
|
Notification: NotificationMock,
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user