import { describe, expect, it } from "vitest"; import { lineDiff } from "../../src/format/diff"; import { formatSvgSource } from "../../src/format/formatter"; describe("explicit formatting and source diff", () => { it("formats only when explicitly requested and retains CRLF style", () => { const source = '\r\nA & B\r\n'; const formatted = formatSvgSource(source); expect(formatted).toContain("\r\n \r\n A & B"); expect(formatted).toContain(' a="1" z="2"'); expect(formatted.endsWith("\r\n")).toBe(true); }); it("refuses to format malformed XML", () => { expect(() => formatSvgSource(" { expect(lineDiff("a\nb\nc", "a\nx\nc")).toEqual([ { kind: "same", text: "a", oldLine: 1, newLine: 1 }, { kind: "add", text: "x", newLine: 2 }, { kind: "remove", text: "b", oldLine: 2 }, { kind: "same", text: "c", oldLine: 3, newLine: 3 }, ]); }); it("falls back to bounded summaries for large comparisons", () => { expect(lineDiff("a\nb\nc", "d\ne\nf", 2)).toEqual([ { kind: "remove", text: "3 lines (5 characters)", oldLine: 1 }, { kind: "add", text: "3 lines (5 characters)", newLine: 1 }, ]); }); });