test: guard extension provider mock calls

This commit is contained in:
Peter Steinberger
2026-05-12 10:04:44 +01:00
parent dbbb7f0aaf
commit b3ded351e3
10 changed files with 10 additions and 10 deletions

View File

@@ -64,7 +64,7 @@ describe("Google Meet OAuth", () => {
expect(tokens.tokenType).toBe("Bearer");
expect(Number.isFinite(tokens.expiresAt)).toBe(true);
expect(tokens.expiresAt).toBeGreaterThan(Date.now());
const body = fetchMock.mock.calls[0]?.[1]?.body;
const body = fetchMock.mock.calls.at(0)?.[1]?.body;
expect(body).toBeInstanceOf(URLSearchParams);
const params = body as URLSearchParams;
expect(params.get("grant_type")).toBe("refresh_token");

View File

@@ -52,7 +52,7 @@ function fetchRequest(fetchMock: ReturnType<typeof vi.fn>): {
method?: string;
url: string;
} {
const [url, init] = fetchMock.mock.calls[0] as [string, RequestInit | undefined];
const [url, init] = fetchMock.mock.calls.at(0) as [string, RequestInit | undefined];
expect(typeof url).toBe("string");
if (!init) {
throw new Error("Expected fetch init");

View File

@@ -287,7 +287,7 @@ describe("google video generation provider", () => {
durationSeconds: 3,
});
const [{ downloadPath }] = downloadMock.mock.calls[0] ?? [{}];
const [{ downloadPath }] = downloadMock.mock.calls.at(0) ?? [{}];
const downloadBaseName = path.basename(String(downloadPath));
expect(downloadBaseName).toContain("video-1.mp4");
expect(downloadBaseName).toMatch(/\.part$/);

View File

@@ -119,7 +119,7 @@ describe("gradium tts diagnostics", () => {
});
expect(fetchMock).toHaveBeenCalledOnce();
const [url, init] = fetchMock.mock.calls[0] as [string, RequestInit];
const [url, init] = fetchMock.mock.calls.at(0) as [string, RequestInit];
expect(url).toBe("https://api.gradium.ai/api/post/speech/tts");
expect(init.method).toBe("POST");
const headers = new Headers(init.headers);

View File

@@ -203,7 +203,7 @@ describe("imessage message actions", () => {
).rejects.toThrow(/imsg private API bridge/);
expect(loggerMock.warn).toHaveBeenCalledTimes(1);
const warnArg = String(loggerMock.warn.mock.calls[0][0]);
const warnArg = String(loggerMock.warn.mock.calls.at(0)?.[0]);
expect(warnArg).toMatch(/iMessage react blocked: private API bridge unavailable/);
expect(warnArg).toMatch(/imsg launch/);
expect(runtimeMock.sendReaction).not.toHaveBeenCalled();

View File

@@ -196,7 +196,7 @@ describe("irc inbound behavior", () => {
const assembledRequest = (
coreRuntime.channel.turn.runAssembled as unknown as { mock: { calls: unknown[][] } }
).mock.calls[0]?.[0] as { replyPipeline?: unknown } | undefined;
).mock.calls.at(0)?.[0] as { replyPipeline?: unknown } | undefined;
expect(assembledRequest?.replyPipeline).toEqual({});
});
});

View File

@@ -51,7 +51,7 @@ type WebhookRegistration = {
};
function requireWebhookRegistration(): WebhookRegistration {
const registration = registerWebhookTargetWithPluginRouteMock.mock.calls[0]?.[0] as
const registration = registerWebhookTargetWithPluginRouteMock.mock.calls.at(0)?.[0] as
| WebhookRegistration
| undefined;
if (!registration) {

View File

@@ -418,7 +418,7 @@ describe("LINE send helpers", () => {
);
expect(pushMessageMock).toHaveBeenCalledTimes(1);
const firstCall = pushMessageMock.mock.calls[0] as [
const firstCall = pushMessageMock.mock.calls.at(0) as [
{ messages: Array<{ quickReply?: { items: unknown[] } }> },
];
expect(firstCall[0].messages[0].quickReply?.items).toHaveLength(13);

View File

@@ -26,7 +26,7 @@ describe("validateLineSignature", () => {
expect(validateLineSignature(body, "short", secret)).toBe(false);
expect(spy).toHaveBeenCalledTimes(1);
const [left, right] = spy.mock.calls[0] ?? [];
const [left, right] = spy.mock.calls.at(0) ?? [];
expect(left).toBeInstanceOf(Buffer);
expect(right).toBeInstanceOf(Buffer);
expect(left?.byteLength).toBe(right?.byteLength);

View File

@@ -193,7 +193,7 @@ describe("litellm image generation provider", () => {
});
expect(mockObjectArg(postJsonRequestMock).url).toBe("http://localhost:4000/images/edits");
const call = postJsonRequestMock.mock.calls[0][0] as { body: { images: unknown[] } };
const call = postJsonRequestMock.mock.calls.at(0)?.[0] as { body: { images: unknown[] } };
expect(call.body.images).toHaveLength(1);
});