Files
OmniRoute/tests/unit/chatcore-nonstreaming-json-response.test.ts
Randi e9c739184e fix: frame non-streaming JSON responses (#5416)
Integrated into release/v3.8.42
2026-06-29 19:23:59 -03:00

23 lines
809 B
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { buildNonStreamingJsonResponse } from "../../open-sse/handlers/chatCore/nonStreamingJsonResponse";
test("buildNonStreamingJsonResponse sets content-length for the serialized JSON body", async () => {
const response = buildNonStreamingJsonResponse(
{
id: "chatcmpl-test",
choices: [{ message: { role: "assistant", content: "hello" } }],
},
{
"Content-Type": "application/json",
"X-OmniRoute-Cache": "MISS",
}
);
const text = await response.text();
assert.equal(response.headers.get("Content-Type"), "application/json");
assert.equal(response.headers.get("X-OmniRoute-Cache"), "MISS");
assert.equal(response.headers.get("Content-Length"), String(Buffer.byteLength(text)));
});