


























@@ -7,6 +7,14 @@ describe("gradium speech provider", () => {
7788const provider = buildGradiumSpeechProvider();
9910+const firstFetchCall = (fetchMock: ReturnType<typeof vi.fn>): [string, RequestInit] => {
11+const call = fetchMock.mock.calls[0] as [string, RequestInit] | undefined;
12+if (!call) {
13+throw new Error("expected Gradium fetch call");
14+}
15+return call;
16+};
17+1018afterEach(() => {
1119vi.unstubAllGlobals();
1220vi.restoreAllMocks();
@@ -52,7 +60,7 @@ describe("gradium speech provider", () => {
5260});
53615462expect(fetchMock).toHaveBeenCalledOnce();
55-const [url, init] = fetchMock.mock.calls.at(0) as [string, RequestInit];
63+const [url, init] = firstFetchCall(fetchMock);
5664expect(url).toBe("https://api.gradium.ai/api/post/speech/tts");
5765const headers = new Headers(init.headers);
5866expect(headers.get("x-api-key")).toBe("gsk_test123");
@@ -82,7 +90,7 @@ describe("gradium speech provider", () => {
8290timeoutMs: 30_000,
8391});
849285-const [, init] = fetchMock.mock.calls.at(0) as [string, RequestInit];
93+const [, init] = firstFetchCall(fetchMock);
8694expect(JSON.parse(init.body as string).output_format).toBe("opus");
8795expect(result.outputFormat).toBe("opus");
8896expect(result.fileExtension).toBe(".opus");
@@ -107,7 +115,7 @@ describe("gradium speech provider", () => {
107115timeoutMs: 30_000,
108116});
109117110-const [, init] = fetchMock.mock.calls.at(0) as [string, RequestInit];
118+const [, init] = firstFetchCall(fetchMock);
111119expect(JSON.parse(init.body as string)).toEqual({
112120text: "Telephony test",
113121voice_id: "override-voice",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。