diff --git a/packages/main/src/plugin/index.spec.ts b/packages/main/src/plugin/index.spec.ts index 2ba08a5dbcc..86203442b1b 100644 --- a/packages/main/src/plugin/index.spec.ts +++ b/packages/main/src/plugin/index.spec.ts @@ -175,3 +175,19 @@ test('Check SecurityRestrictions on known domains', async () => { // expect openExternal has been called expect(shell.openExternal).toBeCalledWith('https://www.podman-desktop.io'); }); + +test('Should apiSender handle local receive events', async () => { + const apiSender = pluginSystem.getApiSender(webContents); + expect(apiSender).toBeDefined(); + + let fooReceived = ''; + apiSender.receive('foo', (data: any) => { + fooReceived = String(data); + }); + + // try to send data + apiSender.send('foo', 'hello-world'); + + // data should have been received + expect(fooReceived).toBe('hello-world'); +}); diff --git a/packages/main/src/plugin/index.ts b/packages/main/src/plugin/index.ts index fe9f09cc089..bb17479ba80 100644 --- a/packages/main/src/plugin/index.ts +++ b/packages/main/src/plugin/index.ts @@ -281,6 +281,7 @@ export class PluginSystem { // add to the queue queuedEvents.push({ channel, data }); } + eventEmitter.emit(channel, data); }, // eslint-disable-next-line @typescript-eslint/no-explicit-any receive: (channel: string, func: any) => {