[PM-6426] Adding jest tests to the ForegroundTaskSchedulerService and the BackgroundTaskSchedulerService

This commit is contained in:
Cesar Gonzalez 2024-06-07 06:45:18 -05:00
parent 8d45abbced
commit b89005feb3
No known key found for this signature in database
GPG Key ID: 3381A5457F8CCECF
2 changed files with 3 additions and 0 deletions

View File

@ -68,6 +68,8 @@ describe("BackgroundTaskSchedulerService", () => {
triggerPortOnDisconnectEvent(portMock);
expect(backgroundTaskSchedulerService["ports"].size).toBe(0);
expect(portMock.onMessage.removeListener).toHaveBeenCalled();
expect(portMock.onDisconnect.removeListener).toHaveBeenCalled();
});
});

View File

@ -41,6 +41,7 @@ export class BackgroundTaskSchedulerService extends BrowserTaskSchedulerServiceI
*/
private handlePortOnDisconnect = (port: chrome.runtime.Port) => {
port.onMessage.removeListener(this.handlePortMessage);
port.onDisconnect.removeListener(this.handlePortOnDisconnect);
this.ports.delete(port);
};