




















@@ -36,25 +36,44 @@ describe("describeQwenVideo", () => {
3636expect(result.model).toBe("qwen-vl-max");
3737expect(result.text).toBe("first\nsecond");
3838expect(url).toBe("https://example.com/v1/chat/completions");
39-expect(init?.method).toBe("POST");
40-expect(init?.signal).toBeInstanceOf(AbortSignal);
39+expect(init).toBeDefined();
40+if (!init) {
41+throw new Error("expected Qwen request init");
42+}
43+expect(init.method).toBe("POST");
44+expect(init.signal).toBeInstanceOf(AbortSignal);
414542-const headers = new Headers(init?.headers);
46+const headers = new Headers(init.headers);
4347expect(headers.get("authorization")).toBe("Bearer test-key");
4448expect(headers.get("content-type")).toBe("application/json");
4549expect(headers.get("x-other")).toBe("1");
46504751const bodyText =
48-typeof init?.body === "string"
52+typeof init.body === "string"
4953 ? init.body
50- : Buffer.isBuffer(init?.body)
54+ : Buffer.isBuffer(init.body)
5155 ? init.body.toString("utf8")
5256 : "";
57+expect(bodyText).not.toBe("");
5358const body = JSON.parse(bodyText);
5459expect(body.model).toBe("qwen-vl-max");
55-expect(body.messages?.[0]?.content?.[0]?.text).toBe("summarize the clip");
56-expect(body.messages?.[0]?.content?.[1]?.type).toBe("video_url");
57-expect(body.messages?.[0]?.content?.[1]?.video_url?.url).toBe(
60+const content = body.messages?.[0]?.content;
61+expect(content).toBeDefined();
62+if (!content) {
63+throw new Error("expected Qwen user content");
64+}
65+expect(content[0]?.text).toBe("summarize the clip");
66+const videoContent = content[1];
67+expect(videoContent).toBeDefined();
68+if (!videoContent) {
69+throw new Error("expected Qwen video content");
70+}
71+expect(videoContent.type).toBe("video_url");
72+expect(videoContent.video_url).toBeDefined();
73+if (!videoContent.video_url) {
74+throw new Error("expected Qwen video URL payload");
75+}
76+expect(videoContent.video_url.url).toBe(
5877`data:video/mp4;base64,${Buffer.from("video-bytes").toString("base64")}`,
5978);
6079});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。