|
1 | 1 | import { describe, expect, it } from "vite-plus/test"; |
2 | 2 |
|
3 | | -import { buildTurnDiffTree } from "~/lib/turnDiffTree"; |
4 | 3 | import { |
| 4 | + buildCommitFileTree, |
5 | 5 | flattenCommitFileTree, |
6 | 6 | resolveCommitFileTreeSelection, |
7 | 7 | toggleCommitFileTreeNode, |
8 | 8 | } from "./CommitFileTree.logic"; |
9 | 9 |
|
10 | | -const tree = buildTurnDiffTree([ |
11 | | - { path: "src/app/page.tsx", additions: 1, deletions: 0 }, |
12 | | - { path: "src/app/layout.tsx", additions: 2, deletions: 1 }, |
13 | | - { path: "src/lib/util.ts", additions: 3, deletions: 0 }, |
14 | | - { path: "README.md", additions: 1, deletions: 1 }, |
| 10 | +const tree = buildCommitFileTree([ |
| 11 | + { path: "src/app/page.tsx", insertions: 1, deletions: 0 }, |
| 12 | + { path: "src/app/layout.tsx", insertions: 2, deletions: 1 }, |
| 13 | + { path: "src/lib/util.ts", insertions: 3, deletions: 0 }, |
| 14 | + { path: "README.md", insertions: 1, deletions: 1 }, |
15 | 15 | ]); |
16 | 16 | const src = tree[0]!; |
17 | 17 |
|
@@ -50,4 +50,18 @@ describe("commit file tree", () => { |
50 | 50 | const partial = new Set(["src/lib/util.ts", "README.md"]); |
51 | 51 | expect([...toggleCommitFileTreeNode(src, partial)]).toEqual(["README.md"]); |
52 | 52 | }); |
| 53 | + |
| 54 | + it("keeps a backslash in a Git path as part of the file name", () => { |
| 55 | + const [docs] = buildCommitFileTree([ |
| 56 | + { path: "docs/a\\b.md", insertions: 1, deletions: 0 }, |
| 57 | + { path: "docs/c.md", insertions: 1, deletions: 0 }, |
| 58 | + ]); |
| 59 | + |
| 60 | + expect(flattenCommitFileTree([docs!], new Set()).map((row) => row.node.path)).toEqual([ |
| 61 | + "docs", |
| 62 | + "docs/a\\b.md", |
| 63 | + "docs/c.md", |
| 64 | + ]); |
| 65 | + expect([...toggleCommitFileTreeNode(docs!, new Set())]).toEqual(["docs/a\\b.md", "docs/c.md"]); |
| 66 | + }); |
53 | 67 | }); |
0 commit comments