1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/packages/technical-features/messaging/electron/renderer/src/allow-communication-to-iframe.test.ts
Janne Savolainen 13f1d6f7f3
chore: Adapt to injectable feature-wrappers
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
2023-04-17 11:47:11 +03:00

33 lines
1.3 KiB
TypeScript

import { createContainer, DiContainer } from "@ogre-tools/injectable";
import { startApplicationInjectionToken } from "@k8slens/application";
import { registerFeature } from "@k8slens/feature-core";
import { messagingFeatureForRenderer } from "./feature";
import { runInAction } from "mobx";
import ipcRendererInjectable from "./ipc/ipc-renderer.injectable";
import { sendMessageToChannelInjectionToken } from "@k8slens/messaging";
import { frameCommunicationAdminChannel } from "./allow-communication-to-iframe.injectable";
describe("allow communication to iframe", () => {
let di: DiContainer;
let sendMessageToChannelMock: jest.Mock;
beforeEach(() => {
di = createContainer("irrelevant");
runInAction(() => {
registerFeature(di, messagingFeatureForRenderer);
});
di.override(ipcRendererInjectable, () => ({ on: () => {} } as unknown));
sendMessageToChannelMock = jest.fn();
di.override(sendMessageToChannelInjectionToken, () => sendMessageToChannelMock);
});
it("when application starts, sends message to communication channel to register the frame ID and process ID for further usage", async () => {
await di.inject(startApplicationInjectionToken)();
expect(sendMessageToChannelMock).toHaveBeenCalledWith(frameCommunicationAdminChannel);
});
});