test: dedupe openai tts mock reads

This commit is contained in:
Peter Steinberger
2026-05-13 06:23:44 +01:00
parent 30af076000
commit 7bb2153fb2

View File

@@ -44,7 +44,7 @@ const officialEndpointValidationCases = [
];
function firstFetchCall(fetchMock: ReturnType<typeof vi.fn>): unknown[] {
const call = fetchMock.mock.calls.at(0);
const call = fetchMock.mock.calls[0];
if (!call) {
throw new Error("expected fetch call");
}
@@ -52,7 +52,7 @@ function firstFetchCall(fetchMock: ReturnType<typeof vi.fn>): unknown[] {
}
function firstFetchInit(fetchMock: ReturnType<typeof vi.fn>): RequestInit {
const init = firstFetchCall(fetchMock).at(1);
const init = firstFetchCall(fetchMock)[1];
if (!init || typeof init !== "object") {
throw new Error("expected fetch init");
}
@@ -164,7 +164,7 @@ describe("openai tts", () => {
timeoutMs: 5_000,
});
const url = firstFetchCall(fetchMock).at(0);
const url = firstFetchCall(fetchMock)[0];
const init = firstFetchInit(fetchMock);
const headers = init?.headers as Record<string, string> | undefined;
expect(url).toBe("https://api.openai.com/v1/audio/speech");