import { describe, expect, it } from "vitest"; import { mergeStreamingText } from "./streaming-card.js"; describe("mergeStreamingText", () => { it("prefers the latest full text when it already includes prior text", () => { expect(mergeStreamingText("hello", "hello world")).toBe("hello world"); }); it("keeps previous text when the next partial is empty or redundant", () => { expect(mergeStreamingText("hello", "")).toBe("hello"); expect(mergeStreamingText("hello world", "hello")).toBe("hello world"); }); it("appends fragmented chunks without injecting newlines", () => { expect(mergeStreamingText("hello wor", "ld")).toBe("hello world"); expect(mergeStreamingText("line1", "line2")).toBe("line1line2"); }); });