From eed8c5fe9109344c0012258a4154bfdf6fbe74ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zachary=20Gu=C3=A9not?= Date: Tue, 8 Sep 2026 15:03:47 +0200 Subject: [PATCH] fix(integrations): type unifi-os test fetch mocks for tsc Co-Authored-By: Claude Opus 5 --- .../src/unifi-os/test/unifi-os-api.spec.ts | 10 +++++++--- .../src/unifi-os/test/unifi-sm-api.spec.ts | 8 +++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/integrations/src/unifi-os/test/unifi-os-api.spec.ts b/packages/integrations/src/unifi-os/test/unifi-os-api.spec.ts index 1643dea89..d9caf23a9 100644 --- a/packages/integrations/src/unifi-os/test/unifi-os-api.spec.ts +++ b/packages/integrations/src/unifi-os/test/unifi-os-api.spec.ts @@ -1,5 +1,5 @@ // @vitest-environment node -import { Response } from "undici"; +import { Response, type RequestInit } from "undici"; import { describe, expect, test, vi } from "vitest"; vi.hoisted(() => { @@ -32,7 +32,9 @@ const createApi = (handler: (url: string) => Promise) => { describe("UnifiOsApi request shape", () => { test("prefixes the integration path and sends the API key header", async () => { - const fetchAsync = vi.fn(async () => jsonResponse({ applicationVersion: "10.6.102" })); + const fetchAsync = vi.fn(async (_url: string, _init?: RequestInit) => + jsonResponse({ applicationVersion: "10.6.102" }), + ); const api = new UnifiOsApi(ORIGIN, API_KEY, fetchAsync as never); await api.getInfoAsync(); @@ -44,7 +46,9 @@ describe("UnifiOsApi request shape", () => { }); test("does not double a slash when the origin has a trailing one", async () => { - const fetchAsync = vi.fn(async () => jsonResponse({ applicationVersion: "10.6.102" })); + const fetchAsync = vi.fn(async (_url: string, _init?: RequestInit) => + jsonResponse({ applicationVersion: "10.6.102" }), + ); const api = new UnifiOsApi(`${ORIGIN}/`, API_KEY, fetchAsync as never); await api.getInfoAsync(); diff --git a/packages/integrations/src/unifi-os/test/unifi-sm-api.spec.ts b/packages/integrations/src/unifi-os/test/unifi-sm-api.spec.ts index aff34e8de..d634089bb 100644 --- a/packages/integrations/src/unifi-os/test/unifi-sm-api.spec.ts +++ b/packages/integrations/src/unifi-os/test/unifi-sm-api.spec.ts @@ -1,5 +1,5 @@ // @vitest-environment node -import { Response } from "undici"; +import { Response, type RequestInit } from "undici"; import { afterEach, beforeEach, describe, expect, test, vi } from "vitest"; vi.hoisted(() => { @@ -46,7 +46,7 @@ const metricsBody = (metricTime: string) => ({ }); const createApi = () => { - const fetchAsync = vi.fn(async (url: string) => + const fetchAsync = vi.fn(async (url: string, _init?: RequestInit) => url.includes("isp-metrics") ? jsonResponse(metricsBody("2026-09-08T09:10:00Z")) : jsonResponse(sitesBody), ); return { api: new UnifiSmApi("cloud-key", fetchAsync as never), fetchAsync }; @@ -130,7 +130,9 @@ describe("UnifiSmApi getIspMetricsAsync", () => { }); test("returns null when the cloud rejects the key rather than propagating", async () => { - const fetchAsync = vi.fn(async () => jsonResponse({ message: "unauthorized" }, 401)); + const fetchAsync = vi.fn(async (_url: string, _init?: RequestInit) => + jsonResponse({ message: "unauthorized" }, 401), + ); const api = new UnifiSmApi("bad-key", fetchAsync as never); expect(await api.getIspMetricsAsync(GATEWAY_MAC)).toBeNull();