diff --git a/extensions/minimax/video-generation-provider.test.ts b/extensions/minimax/video-generation-provider.test.ts index fc6a5097eb9..bf74bc47a6e 100644 --- a/extensions/minimax/video-generation-provider.test.ts +++ b/extensions/minimax/video-generation-provider.test.ts @@ -27,6 +27,19 @@ beforeAll(async () => { installMinimaxProviderHttpMockCleanup(); +function expectMinimaxFetchCall(index: number, url: string) { + const call = fetchWithTimeoutMock.mock.calls[index]; + if (!call) { + throw new Error(`expected MiniMax fetch call ${index + 1}`); + } + const [actualUrl, init, timeoutMs, fetchFn] = call; + expect(actualUrl).toBe(url); + expect(init).toMatchObject({ method: "GET" }); + expect(Number.isInteger(timeoutMs)).toBe(true); + expect(timeoutMs).toBeGreaterThan(0); + expect(fetchFn).toBe(fetch); +} + describe("minimax video generation provider", () => { it("declares explicit mode capabilities", () => { const provider = buildMinimaxVideoGenerationProvider(); @@ -131,24 +144,8 @@ describe("minimax video generation provider", () => { cfg: {}, }); - expect(fetchWithTimeoutMock).toHaveBeenNthCalledWith( - 2, - "https://api.minimax.io/v1/files/retrieve?file_id=file-9", - expect.objectContaining({ - method: "GET", - }), - expect.any(Number), - expect.any(Function), - ); - expect(fetchWithTimeoutMock).toHaveBeenNthCalledWith( - 3, - "https://example.com/download.mp4", - expect.objectContaining({ - method: "GET", - }), - expect.any(Number), - expect.any(Function), - ); + expectMinimaxFetchCall(1, "https://api.minimax.io/v1/files/retrieve?file_id=file-9"); + expectMinimaxFetchCall(2, "https://example.com/download.mp4"); expect(result.videos).toHaveLength(1); expect(result.metadata).toEqual( expect.objectContaining({ @@ -222,14 +219,9 @@ describe("minimax video generation provider", () => { url: "https://api.minimaxi.com/v1/video_generation", }), ); - expect(fetchWithTimeoutMock).toHaveBeenNthCalledWith( - 1, + expectMinimaxFetchCall( + 0, "https://api.minimaxi.com/v1/query/video_generation?task_id=task-portal", - expect.objectContaining({ - method: "GET", - }), - expect.any(Number), - expect.any(Function), ); }); });