Skip to content
Source
Sign inSign up

pullRequestReviewDrafts.test.ts

34 lines972 Bytes

1import { describe, expect, it } from "vite-plus/test";
2import { clearSubmittedReview, type ReviewDraft } from "./pullRequestReviewDrafts";
3const comment = {
4 id: "one",
5 path: "renamed.ts",
6 oldPath: "old.ts",
7 position: { kind: "deleted" as const, oldLine: 9 },
8 body: "Keep this",
9 headSha: "abc",
10 code: "old line",
11};
12const draft: ReviewDraft = {
13 summary: "Review",
14 comment: "Separate PR comment",
15 comments: [comment],
16};
17describe("mobile review draft recovery", () => {
18 it("clears a submitted snapshot while retaining edits made during the request", () => {
19 const current = {
20 ...draft,
21 summary: "New summary",
22 comments: [
23 { ...comment, body: "New feedback" },
24 { ...comment, id: "two" },
25 ],
26 };
27 expect(clearSubmittedReview(current, draft)).toEqual(current);
28 expect(clearSubmittedReview(draft, draft)).toEqual({
29 summary: "",
30 comment: draft.comment,
31 comments: [],
32 });
33 });
34});