| ... | ... | @@ -1,65 +0,0 @@ |
| 1 | | import type { ReactNode } from "react"; |
| 2 | | import { renderToStaticMarkup } from "react-dom/server"; |
| 3 | | import { beforeEach, describe, expect, it, vi } from "vite-plus/test"; |
| 4 | | |
| 5 | | const testState = vi.hoisted(() => ({ |
| 6 | | codeViewOptions: null as Record<string, unknown> | null, |
| 7 | | })); |
| 8 | | |
| 9 | | vi.mock("@pierre/diffs/react", () => ({ |
| 10 | | CodeView: (props: { options: Record<string, unknown> }) => { |
| 11 | | testState.codeViewOptions = props.options; |
| 12 | | return null; |
| 13 | | }, |
| 14 | | })); |
| 15 | | |
| 16 | | vi.mock("../DiffWorkerPoolProvider", () => ({ |
| 17 | | DiffWorkerPoolProvider: ({ children }: { children?: ReactNode }) => children, |
| 18 | | })); |
| 19 | | |
| 20 | | vi.mock("~/composerDraftStore", () => ({ |
| 21 | | useComposerDraftStore: (selector: (store: Record<string, unknown>) => unknown) => |
| 22 | | selector({ |
| 23 | | addReviewComment: vi.fn(), |
| 24 | | removeReviewComment: vi.fn(), |
| 25 | | getComposerDraft: () => undefined, |
| 26 | | }), |
| 27 | | })); |
| 28 | | |
| 29 | | vi.mock("./DiffCommentAnnotation", () => ({ |
| 30 | | DiffCommentAnnotation: () => null, |
| 31 | | })); |
| 32 | | |
| 33 | | vi.mock("../files/fileCommentAnnotations", () => ({ |
| 34 | | nextFileCommentId: () => "comment-test", |
| 35 | | })); |
| 36 | | |
| 37 | | import { AnnotatableCodeView } from "./AnnotatableCodeView"; |
| 38 | | |
| 39 | | describe("AnnotatableCodeView", () => { |
| 40 | | beforeEach(() => { |
| 41 | | testState.codeViewOptions = null; |
| 42 | | }); |
| 43 | | |
| 44 | | it("opens comments from Pierre's gutter action without ending line selection", () => { |
| 45 | | renderToStaticMarkup( |
| 46 | | <AnnotatableCodeView |
| 47 | | codeViewKey="test-view" |
| 48 | | files={[]} |
| 49 | | sectionId="working-tree" |
| 50 | | sectionTitle="Working tree" |
| 51 | | composerDraftTarget={"draft-test" as never} |
| 52 | | options={{}} |
| 53 | | renderHeaderPrefix={() => null} |
| 54 | | renderHeaderFilenameSuffix={() => null} |
| 55 | | />, |
| 56 | | ); |
| 57 | | |
| 58 | | expect(testState.codeViewOptions).toMatchObject({ |
| 59 | | enableGutterUtility: true, |
| 60 | | enableLineSelection: true, |
| 61 | | onGutterUtilityClick: expect.any(Function), |
| 62 | | }); |
| 63 | | expect(testState.codeViewOptions).not.toHaveProperty("onLineSelectionEnd"); |
| 64 | | }); |
| 65 | | }); |