@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 22 lines 979 Bytes
Raw
1 import { describe, expect, it } from "vite-plus/test";
2 import { buildReviewParsedDiff } from "../review/reviewModel";
3 import { groupByDirectory } from "./pullRequestFileSections";
4
5 function patch(path: string) {
6 return `diff --git a/${path} b/${path}\n--- a/${path}\n+++ b/${path}\n@@ -1 +1 @@\n-old\n+new\n`;
7 }
8
9 describe("groupByDirectory", () => {
10 it("keeps review order when a parent directory resumes after a subdirectory", () => {
11 const parsed = buildReviewParsedDiff(
12 ["src/a.ts", "src/lib/b.ts", "src/z.ts"].map(patch).join("\n"),
13 "pr",
14 );
15 if (parsed.kind !== "files") throw new Error("Expected files");
16 const items = groupByDirectory(parsed.files, new Set());
17 expect(
18 items.map((item) => (item.kind === "directory" ? `${item.directory}/` : item.file.path)),
19 ).toEqual(["src/", "src/a.ts", "src/lib/", "src/lib/b.ts", "src/", "src/z.ts"]);
20 expect(new Set(items.map((item) => item.key)).size).toBe(items.length);
21 });
22 });