OXYGENHUB
◆ main oxygen-vscode / test / diffutil.test.mjs
718 B · last changed Milestone 0.4: history graph webview with per-change actions, file history diffs between versions, inline blame aligned to unsaved edits with a Myers line diff 1 month ago source blame history raw
1
import { test } from "node:test";
2
import assert from "node:assert/strict";
3
import { alignLines } from "../out/diffutil.mjs";
4
5
test("alignLines maps unchanged lines through insertions and deletions", () => {
6
  const before = ["a", "b", "c", "d", "e"];
7
  const after = ["a", "x", "b", "d", "e", "f"];
8
  assert.deepEqual(alignLines(before, after), [0, -1, 1, 3, 4, -1]);
9
  assert.deepEqual(alignLines([], ["a"]), [-1]);
10
  assert.deepEqual(alignLines(["a"], []), []);
11
  assert.deepEqual(alignLines(["same", "same"], ["same", "same"]), [0, 1]);
12
  const moved = alignLines(["1", "2", "3", "4"], ["3", "4", "1", "2"]);
13
  assert.equal(moved.filter((i) => i >= 0).length, 2, "one block matches, the other reads as moved");
14
});