import test from "node:test";
import assert from "node:assert/strict";
import { parseDiffLines } from "./diff-lines.js";

test("classifies diff additions and deletions without coloring headers", () => {
  const result = parseDiffLines("--- a/file.txt\n+++ b/file.txt\n-old\n+new\n same");
  assert.deepEqual(result.map((line) => line.kind), [
    "header", "header", "deletion", "addition", "context"
  ]);
});

test("adds display line numbers and folded unchanged rows from hunk headers", () => {
  const result = parseDiffLines("@@ -108,2 +108,2 @@\n same\n-old\n+new");

  assert.deepEqual(result, [
    { id: "fold-0-107", kind: "fold", text: "107 unchanged lines", count: 107 },
    { id: "1- same", text: " same", kind: "context", oldLine: 108, newLine: 108, lineNumber: 108 },
    { id: "2--old", text: "-old", kind: "deletion", oldLine: 109, newLine: null, lineNumber: 109 },
    { id: "3-+new", text: "+new", kind: "addition", oldLine: null, newLine: 109, lineNumber: 109 }
  ]);
});
