From f142bb0d6b4e00e581b4af087803d3e3abaee6a0 Mon Sep 17 00:00:00 2001 From: Kaspre Date: Mon, 11 May 2026 04:08:45 -0400 Subject: [PATCH] test(extensions): type mocked calls explicitly --- .../openrouter/image-generation-provider.test.ts | 5 +++-- extensions/zalouser/src/zca-client.test.ts | 14 +++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/extensions/openrouter/image-generation-provider.test.ts b/extensions/openrouter/image-generation-provider.test.ts index 77c10970a98..399b1aee824 100644 --- a/extensions/openrouter/image-generation-provider.test.ts +++ b/extensions/openrouter/image-generation-provider.test.ts @@ -114,10 +114,11 @@ describe("openrouter image generation provider", () => { providers: { openrouter: { baseUrl: "https://custom.openrouter.test/api/v1", + models: [], }, }, }, - } as never, + }, }); expect(resolveApiKeyForProviderMock).toHaveBeenCalledOnce(); @@ -219,7 +220,7 @@ describe("openrouter image generation provider", () => { model: "google/gemini-3.1-flash-image-preview", prompt: "turn this into watercolor", inputImages: [{ buffer: Buffer.from("source-image"), mimeType: "image/png" }], - cfg: {} as never, + cfg: {}, }); const body = requireOpenRouterPostBody(); diff --git a/extensions/zalouser/src/zca-client.test.ts b/extensions/zalouser/src/zca-client.test.ts index 27e3d9c5c9c..94aa79c7a23 100644 --- a/extensions/zalouser/src/zca-client.test.ts +++ b/extensions/zalouser/src/zca-client.test.ts @@ -3,10 +3,12 @@ import { describe, expect, it, vi } from "vitest"; describe("zca-client runtime loading", () => { it("does not import zca-js until a session is created", async () => { vi.clearAllMocks(); + let constructedOptions: { logging?: boolean; selfListen?: boolean } | undefined; + function MockZalo(options?: { logging?: boolean; selfListen?: boolean }) { + constructedOptions = options; + } const runtimeFactory = vi.fn(() => ({ - Zalo: class MockZalo { - constructor(public readonly options?: { logging?: boolean; selfListen?: boolean }) {} - }, + Zalo: MockZalo, })); vi.doMock("zca-js", runtimeFactory); @@ -14,12 +16,10 @@ describe("zca-client runtime loading", () => { const zcaClient = await import("./zca-client.js"); expect(runtimeFactory).not.toHaveBeenCalled(); - const client = (await zcaClient.createZalo({ logging: false, selfListen: true })) as { - options?: { logging?: boolean; selfListen?: boolean }; - }; + await zcaClient.createZalo({ logging: false, selfListen: true }); expect(runtimeFactory).toHaveBeenCalledTimes(1); - expect((client as { options?: { logging?: boolean; selfListen?: boolean } }).options).toEqual({ + expect(constructedOptions).toEqual({ logging: false, selfListen: true, });