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

View File

@@ -26,7 +26,12 @@ describe('processUtils', () => {
beforeEach(() => {
_resetRelaunchStateForTesting();
process.send = vi.fn();
process.send = vi.fn(
(_msg: unknown, callback?: (err: Error | null) => void) => {
if (callback) callback(null);
return true;
},
);
});
afterEach(() => {
@@ -46,10 +51,13 @@ describe('processUtils', () => {
await relaunchApp('custom-session-id');
expect(handleAutoUpdate.waitForUpdateCompletion).toHaveBeenCalledTimes(1);
expect(runExitCleanup).toHaveBeenCalledTimes(1);
expect(process.send).toHaveBeenCalledWith({
type: 'relaunch-session',
sessionId: 'custom-session-id',
});
expect(process.send).toHaveBeenCalledWith(
{
type: 'relaunch-session',
sessionId: 'custom-session-id',
},
expect.any(Function),
);
expect(processExit).toHaveBeenCalledWith(RELAUNCH_EXIT_CODE);
});
});

View File

@@ -29,9 +29,14 @@ export async function relaunchApp(sessionId?: string): Promise<void> {
await runExitCleanup();
if (process.send && sessionId) {
process.send({
type: 'relaunch-session',
sessionId,
await new Promise<void>((resolve) => {
process.send!(
{
type: 'relaunch-session',
sessionId,
},
() => resolve(),
);
});
}