45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import { getModel } from "../src/models.js";
|
|
import { streamOpenAIResponses } from "../src/providers/openai-responses.js";
|
|
|
|
describe("openai-responses github-copilot defaults", () => {
|
|
afterEach(() => {
|
|
vi.restoreAllMocks();
|
|
});
|
|
|
|
it("omits reasoning when no reasoning is requested", async () => {
|
|
const model = getModel("github-copilot", "gpt-5-mini");
|
|
let capturedPayload: unknown;
|
|
|
|
vi.spyOn(globalThis, "fetch").mockResolvedValue(
|
|
new Response("data: [DONE]\n\n", {
|
|
status: 200,
|
|
headers: { "content-type": "text/event-stream" },
|
|
}),
|
|
);
|
|
|
|
const stream = streamOpenAIResponses(
|
|
model,
|
|
{
|
|
systemPrompt: "sys",
|
|
messages: [{ role: "user", content: "hi", timestamp: Date.now() }],
|
|
},
|
|
{
|
|
apiKey: "test-key",
|
|
onPayload: (payload) => {
|
|
capturedPayload = payload;
|
|
},
|
|
},
|
|
);
|
|
|
|
for await (const event of stream) {
|
|
if (event.type === "done" || event.type === "error") break;
|
|
}
|
|
|
|
expect(capturedPayload).not.toBeNull();
|
|
expect(capturedPayload).not.toMatchObject({
|
|
reasoning: expect.anything(),
|
|
});
|
|
});
|
|
});
|