import { test, expect } from "vitest"; import { Readable } from "node:stream"; import { attachJsonlReader } from "../src/rpc/line-splitter.js"; test("riassembla righe spezzate tra chunk, split solo su \\n", async () => { const lines: string[] = []; const s = new Readable({ read() {} }); attachJsonlReader(s, (l) => lines.push(l)); s.push('{"a":1}\n{"b":'); s.push('2}\r\n{"u":" in stringa"}\n'); s.push(null); await new Promise((r) => s.on("end", r)); expect(lines).toEqual(['{"a":1}', '{"b":2}', '{"u":" in stringa"}']); });