test(extensions): type mocked calls explicitly

This commit is contained in:
Kaspre
2026-05-11 04:08:45 -04:00
committed by Peter Steinberger
parent 528ab7ed4d
commit f142bb0d6b
2 changed files with 10 additions and 9 deletions

View File

@@ -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();

View File

@@ -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,
});