From fa126d43fba76fbda80b13b42375ea4f0583d364 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 9 May 2026 05:14:38 +0100 Subject: [PATCH] test: tighten media image provider assertions --- src/media-understanding/image.test.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/media-understanding/image.test.ts b/src/media-understanding/image.test.ts index 16ce4471b7d..1ea5a53e1e1 100644 --- a/src/media-understanding/image.test.ts +++ b/src/media-understanding/image.test.ts @@ -162,9 +162,10 @@ describe("describeImageWithModel", () => { prompt: "Describe the image.", image_url: `data:image/png;base64,${Buffer.from("png-bytes").toString("base64")}`, }), - signal: expect.any(AbortSignal), }), ); + const [, fetchOptions] = fetchMock.mock.calls[0] ?? []; + expect(fetchOptions?.signal).toBeInstanceOf(AbortSignal); expect(timeoutSpy).toHaveBeenCalledWith(1000); expect(completeMock).not.toHaveBeenCalled(); }); @@ -380,13 +381,20 @@ describe("describeImageWithModel", () => { }), ], }), - expect.any(Object), + expect.objectContaining({ + apiKey: "oauth-test", + maxTokens: 512, + }), ); const firstCall = completeMock.mock.calls[0]; if (!firstCall) { throw new Error("Expected image completion call"); } - const [, context] = firstCall; + const [, context, options] = firstCall; + expect(Object.keys(options).toSorted()).toEqual(["apiKey", "maxTokens", "signal", "timeoutMs"]); + expect(options.signal).toBeInstanceOf(AbortSignal); + expect(options.timeoutMs).toBeGreaterThan(0); + expect(options.timeoutMs).toBeLessThanOrEqual(1000); const userMessage = context.messages[0]; if (!userMessage) { throw new Error("expected image completion user message");