chore: Fix types in tests 25/N.

This commit is contained in:
cpojer
2026-02-17 14:31:02 +09:00
parent 600022cdcc
commit 6e5df1dc0f
16 changed files with 118 additions and 78 deletions

View File

@@ -17,7 +17,7 @@ function createForeignSignalHarness() {
}
},
removeEventListener,
} as AbortSignal;
} as unknown as AbortSignal;
return {
fakeSignal,
@@ -38,7 +38,7 @@ describe("wrapFetchWithAbortSignal", () => {
await wrapped("https://example.com", { method: "POST", body: "hi" });
expect(seenInit?.duplex).toBe("half");
expect((seenInit as (RequestInit & { duplex?: string }) | undefined)?.duplex).toBe("half");
});
it("converts foreign abort signals to native controllers", async () => {
@@ -119,7 +119,7 @@ describe("wrapFetchWithAbortSignal", () => {
aborted: false,
addEventListener: (_event: string, _handler: () => void) => {},
removeEventListener,
} as AbortSignal;
} as unknown as AbortSignal;
await expect(wrapped("https://example.com", { signal: fakeSignal })).rejects.toBe(fetchError);
expect(removeEventListener).toHaveBeenCalledOnce();
@@ -141,7 +141,7 @@ describe("wrapFetchWithAbortSignal", () => {
aborted: false,
addEventListener: (_event: string, _handler: () => void) => {},
removeEventListener,
} as AbortSignal;
} as unknown as AbortSignal;
expect(() => wrapped("https://example.com", { signal: fakeSignal })).toThrow(syncError);
expect(removeEventListener).toHaveBeenCalledOnce();
@@ -157,7 +157,7 @@ describe("wrapFetchWithAbortSignal", () => {
aborted: true,
addEventListener,
removeEventListener,
} as AbortSignal;
} as unknown as AbortSignal;
await wrapped("https://example.com", { signal: fakeSignal });
@@ -177,7 +177,7 @@ describe("wrapFetchWithAbortSignal", () => {
const preconnectSpy = vi.fn(function (this: unknown) {
return this;
});
const fetchImpl = vi.fn(async () => ({ ok: true }) as Response) as typeof fetch & {
const fetchImpl = vi.fn(async () => ({ ok: true }) as Response) as unknown as typeof fetch & {
preconnect: (url: string, init?: { credentials?: RequestCredentials }) => unknown;
};
fetchImpl.preconnect = preconnectSpy;