test: tighten together video request assertions

This commit is contained in:
Peter Steinberger
2026-05-09 20:44:28 +01:00
parent 43cf6c4387
commit 5cc6a1397e

View File

@@ -15,6 +15,13 @@ beforeAll(async () => {
installProviderHttpMockCleanup();
function requireRecord(value: unknown, label: string): Record<string, unknown> {
if (value === null || typeof value !== "object" || Array.isArray(value)) {
throw new Error(`expected ${label} to be a record`);
}
return value as Record<string, unknown>;
}
describe("together video generation provider", () => {
it("declares explicit mode capabilities", () => {
expectExplicitVideoGenerationCapabilities(buildTogetherVideoGenerationProvider());
@@ -51,21 +58,22 @@ describe("together video generation provider", () => {
cfg: {},
});
expect(postJsonRequestMock).toHaveBeenCalledWith(
expect.objectContaining({
url: "https://api.together.xyz/v1/videos",
}),
);
expect(postJsonRequestMock).toHaveBeenCalledOnce();
const request = requireRecord(postJsonRequestMock.mock.calls[0]?.[0], "Together request");
expect(request.url).toBe("https://api.together.xyz/v1/videos");
const body = requireRecord(request.body, "Together request body");
expect(body.model).toBe("Wan-AI/Wan2.2-T2V-A14B");
expect(body.prompt).toBe("A bicycle weaving through a rainy neon street");
expect(result.videos).toHaveLength(1);
const [video] = result.videos;
if (!video) {
throw new Error("Expected generated Together video");
}
expect(video.fileName).toBe("video-1.webm");
expect(result.metadata).toEqual(
expect.objectContaining({
videoId: "video_123",
}),
);
expect(result.metadata).toEqual({
videoId: "video_123",
status: "completed",
videoUrl: "https://example.com/together.mp4",
});
});
});