The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { expect, it } from "vite-plus/test"; |
| 2 | import type { NativeReviewDiffRow } from "../../diffs/nativeReviewDiffSurface"; |
| 3 | import { guideFocusedRows } from "./guideDiffFocus"; |
| 4 | |
| 5 | it("focuses a range that crosses diff sides in either direction", () => { |
| 6 | const rows: NativeReviewDiffRow[] = [ |
| 7 | { kind: "file", id: "file", fileId: "f" }, |
| 8 | { kind: "line", id: "a", fileId: "f", oldLineNumber: 12 }, |
| 9 | { kind: "line", id: "b", fileId: "f", oldLineNumber: 13 }, |
| 10 | { kind: "line", id: "c", fileId: "f", newLineNumber: 12 }, |
| 11 | { kind: "line", id: "d", fileId: "f", newLineNumber: 13 }, |
| 12 | { kind: "line", id: "other", fileId: "other", newLineNumber: 13 }, |
| 13 | ]; |
| 14 | expect( |
| 15 | guideFocusedRows(rows, "f", { side: "old", start: 12, endSide: "new", end: 13 }).map( |
| 16 | (row) => row.id, |
| 17 | ), |
| 18 | ).toEqual(["a", "b", "c", "d"]); |
| 19 | expect( |
| 20 | guideFocusedRows(rows, "f", { side: "new", start: 13, endSide: "old", end: 12 }).map( |
| 21 | (row) => row.id, |
| 22 | ), |
| 23 | ).toEqual(["a", "b", "c", "d"]); |
| 24 | expect( |
| 25 | guideFocusedRows(rows, "f", { side: "old", start: 12, end: 13 }).map((row) => row.id), |
| 26 | ).toEqual(["a", "b"]); |
| 27 | expect(guideFocusedRows(rows, "f", { side: "old", start: 99, endSide: "new", end: 13 })).toEqual( |
| 28 | [], |
| 29 | ); |
| 30 | }); |