summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTobias Järvelöv <tobias.jarvelov@mullvad.net>2025-10-01 21:12:50 +0200
committerTobias Järvelöv <tobias.jarvelov@mullvad.net>2025-10-06 10:02:52 +0200
commit82a01dcab68f53bb1fdb444839311f505bd659db (patch)
treeeab4fcfd1a2b58539fab66a66f7016d78a9437ed
parenta7b0f0dec989d17e18e11283f427158ef04c4f7f (diff)
downloadmullvadvpn-82a01dcab68f53bb1fdb444839311f505bd659db.tar.xz
mullvadvpn-82a01dcab68f53bb1fdb444839311f505bd659db.zip
Allow expect IPC mock handle to receive the return value for the handle
-rw-r--r--desktop/packages/mullvad-vpn/test/e2e/mocked/mocked-utils.ts12
1 files changed, 6 insertions, 6 deletions
diff --git a/desktop/packages/mullvad-vpn/test/e2e/mocked/mocked-utils.ts b/desktop/packages/mullvad-vpn/test/e2e/mocked/mocked-utils.ts
index 14ee96e925..bada4ae5ff 100644
--- a/desktop/packages/mullvad-vpn/test/e2e/mocked/mocked-utils.ts
+++ b/desktop/packages/mullvad-vpn/test/e2e/mocked/mocked-utils.ts
@@ -94,9 +94,9 @@ export const createMockIpcExpect = (
) => {
const type = 'type' in spec ? spec.type : 'invoke';
- return <T>(): Promise<T> => {
+ return <T>(response: T): Promise<T> => {
return electronApp.evaluate(
- ({ ipcMain }, { event, type }) => {
+ ({ ipcMain }, { event, type, response }) => {
return new Promise<T>((resolve) => {
if (type === 'send') {
ipcMain.once(event, (_event, arg) => resolve(arg));
@@ -105,13 +105,13 @@ export const createMockIpcExpect = (
resolve(arg);
return {
type: 'success',
- value: null,
+ value: response,
};
});
}
});
},
- { event, type },
+ { event, type, response },
);
};
};
@@ -155,14 +155,14 @@ type IpcMockedTestExtraHandlerKey<
type IpcMockedTestFn<I extends AnyIpcCall> = I['direction'] extends 'main-to-renderer'
? Async<NonNullable<ReturnType<I['send']>>>
- : (response: Awaited<ReturnType<Parameters<ReturnType<I['receive']>>[0]>>) => Promise<void>;
+ : (response?: Awaited<ReturnType<Parameters<ReturnType<I['receive']>>[0]>>) => Promise<void>;
export type IpcMockedTest<S extends Schema> = {
[G in keyof S]: {
[K in keyof S[G]]: {
[C in IpcMockedTestKey<S[G][K]>]: IpcMockedTestFn<S[G][K]>;
} & {
- [C in IpcMockedTestExtraHandlerKey<S[G][K], 'expect'>]: () => Promise<void>;
+ [C in IpcMockedTestExtraHandlerKey<S[G][K], 'expect'>]: IpcMockedTestFn<S[G][K]>;
} & {
[C in IpcMockedTestExtraHandlerKey<S[G][K], 'ignore'>]: () => Promise<void>;
} & {