From 725f63f72401405b5398563b74573dd98eecab53 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 15 Feb 2026 23:51:04 +0000 Subject: [PATCH] perf(test): fold restart recovery helper into spawn utils suite --- src/process/restart-recovery.test.ts | 18 ------------------ src/process/spawn-utils.test.ts | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 18 deletions(-) delete mode 100644 src/process/restart-recovery.test.ts diff --git a/src/process/restart-recovery.test.ts b/src/process/restart-recovery.test.ts deleted file mode 100644 index 5091d7b9928..00000000000 --- a/src/process/restart-recovery.test.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { describe, expect, it, vi } from "vitest"; -import { createRestartIterationHook } from "./restart-recovery.js"; - -describe("restart-recovery", () => { - it("skips recovery on first iteration and runs on subsequent iterations", () => { - const onRestart = vi.fn(); - const onIteration = createRestartIterationHook(onRestart); - - expect(onIteration()).toBe(false); - expect(onRestart).not.toHaveBeenCalled(); - - expect(onIteration()).toBe(true); - expect(onRestart).toHaveBeenCalledTimes(1); - - expect(onIteration()).toBe(true); - expect(onRestart).toHaveBeenCalledTimes(2); - }); -}); diff --git a/src/process/spawn-utils.test.ts b/src/process/spawn-utils.test.ts index cb3e0dc1dc0..b5e134ca623 100644 --- a/src/process/spawn-utils.test.ts +++ b/src/process/spawn-utils.test.ts @@ -2,6 +2,7 @@ import type { ChildProcess } from "node:child_process"; import { EventEmitter } from "node:events"; import { PassThrough } from "node:stream"; import { describe, expect, it, vi } from "vitest"; +import { createRestartIterationHook } from "./restart-recovery.js"; import { spawnWithFallback } from "./spawn-utils.js"; function createStubChild() { @@ -61,3 +62,19 @@ describe("spawnWithFallback", () => { expect(spawnMock).toHaveBeenCalledTimes(1); }); }); + +describe("restart-recovery", () => { + it("skips recovery on first iteration and runs on subsequent iterations", () => { + const onRestart = vi.fn(); + const onIteration = createRestartIterationHook(onRestart); + + expect(onIteration()).toBe(false); + expect(onRestart).not.toHaveBeenCalled(); + + expect(onIteration()).toBe(true); + expect(onRestart).toHaveBeenCalledTimes(1); + + expect(onIteration()).toBe(true); + expect(onRestart).toHaveBeenCalledTimes(2); + }); +});