| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { resolveSelectedReviewFileId } from "./reviewPaneSelection"; |
| 4 | |
| 5 | describe("resolveSelectedReviewFileId", () => { |
| 6 | it("keeps a visible file selected within the active section", () => { |
| 7 | expect( |
| 8 | resolveSelectedReviewFileId({ |
| 9 | selection: { sectionId: "worktree", fileId: "second" }, |
| 10 | sectionId: "worktree", |
| 11 | availableFileIds: ["first", "second"], |
| 12 | }), |
| 13 | ).toBe("second"); |
| 14 | }); |
| 15 | |
| 16 | it("clears selection when the review section changes", () => { |
| 17 | expect( |
| 18 | resolveSelectedReviewFileId({ |
| 19 | selection: { sectionId: "turn-1", fileId: "first" }, |
| 20 | sectionId: "turn-2", |
| 21 | availableFileIds: ["first"], |
| 22 | }), |
| 23 | ).toBeNull(); |
| 24 | }); |
| 25 | |
| 26 | it("clears a file that no longer exists in the diff", () => { |
| 27 | expect( |
| 28 | resolveSelectedReviewFileId({ |
| 29 | selection: { sectionId: "worktree", fileId: "removed" }, |
| 30 | sectionId: "worktree", |
| 31 | availableFileIds: ["first", "second"], |
| 32 | }), |
| 33 | ).toBeNull(); |
| 34 | }); |
| 35 | }); |