test: dedupe and optimize test suites

This commit is contained in:
Peter Steinberger
2026-02-19 15:18:50 +00:00
parent b0e55283d5
commit a1cb700a05
80 changed files with 2627 additions and 2962 deletions

View File

@@ -12,6 +12,10 @@ vi.mock("./backoff.js", () => ({
},
}));
function createRuntime() {
return { log: vi.fn(), error: vi.fn(), exit: vi.fn() };
}
describe("waitForTransportReady", () => {
beforeEach(() => {
vi.useFakeTimers();
@@ -22,7 +26,7 @@ describe("waitForTransportReady", () => {
});
it("returns when the check succeeds and logs after the delay", async () => {
const runtime = { log: vi.fn(), error: vi.fn(), exit: vi.fn() };
const runtime = createRuntime();
let attempts = 0;
const readyPromise = waitForTransportReady({
label: "test transport",
@@ -48,7 +52,7 @@ describe("waitForTransportReady", () => {
});
it("throws after the timeout", async () => {
const runtime = { log: vi.fn(), error: vi.fn(), exit: vi.fn() };
const runtime = createRuntime();
const waitPromise = waitForTransportReady({
label: "test transport",
timeoutMs: 110,
@@ -65,7 +69,7 @@ describe("waitForTransportReady", () => {
});
it("returns early when aborted", async () => {
const runtime = { log: vi.fn(), error: vi.fn(), exit: vi.fn() };
const runtime = createRuntime();
const controller = new AbortController();
controller.abort();
await waitForTransportReady({