chore: update test

This commit is contained in:
Jack Wotherspoon
2026-03-09 15:17:34 +01:00
parent 0b3653262c
commit 8849319e8b
2 changed files with 21 additions and 8 deletions
+13 -5
View File
@@ -26,7 +26,12 @@ describe('processUtils', () => {
beforeEach(() => { beforeEach(() => {
_resetRelaunchStateForTesting(); _resetRelaunchStateForTesting();
process.send = vi.fn(); process.send = vi.fn(
(_msg: unknown, callback?: (err: Error | null) => void) => {
if (callback) callback(null);
return true;
},
);
}); });
afterEach(() => { afterEach(() => {
@@ -46,10 +51,13 @@ describe('processUtils', () => {
await relaunchApp('custom-session-id'); await relaunchApp('custom-session-id');
expect(handleAutoUpdate.waitForUpdateCompletion).toHaveBeenCalledTimes(1); expect(handleAutoUpdate.waitForUpdateCompletion).toHaveBeenCalledTimes(1);
expect(runExitCleanup).toHaveBeenCalledTimes(1); expect(runExitCleanup).toHaveBeenCalledTimes(1);
expect(process.send).toHaveBeenCalledWith({ expect(process.send).toHaveBeenCalledWith(
type: 'relaunch-session', {
sessionId: 'custom-session-id', type: 'relaunch-session',
}); sessionId: 'custom-session-id',
},
expect.any(Function),
);
expect(processExit).toHaveBeenCalledWith(RELAUNCH_EXIT_CODE); expect(processExit).toHaveBeenCalledWith(RELAUNCH_EXIT_CODE);
}); });
}); });
+8 -3
View File
@@ -29,9 +29,14 @@ export async function relaunchApp(sessionId?: string): Promise<void> {
await runExitCleanup(); await runExitCleanup();
if (process.send && sessionId) { if (process.send && sessionId) {
process.send({ await new Promise<void>((resolve) => {
type: 'relaunch-session', process.send!(
sessionId, {
type: 'relaunch-session',
sessionId,
},
() => resolve(),
);
}); });
} }