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

main
ts 36 lines 1.23 KB
Raw
1 import { ASSISTANT_CITATION_MAX_COMMENT_LENGTH } from "@t3tools/contracts";
2 import { describe, expect, it } from "vite-plus/test";
3
4 import { resolveAssistantCitationCommentDismissal } from "./assistantCitationCommentDismissal";
5
6 describe("resolveAssistantCitationCommentDismissal", () => {
7 it("commits typed text when the popover is dismissed by clicking away", () => {
8 expect(
9 resolveAssistantCitationCommentDismissal({
10 reason: "outside-press",
11 draft: "needs a retry",
12 savedComment: undefined,
13 }),
14 ).toEqual({ kind: "commit", comment: "needs a retry" });
15 });
16
17 it("commits an edited comment when focus leaves the popover", () => {
18 expect(
19 resolveAssistantCitationCommentDismissal({
20 reason: "focus-out",
21 draft: "second thought",
22 savedComment: "first thought",
23 }),
24 ).toEqual({ kind: "commit", comment: "second thought" });
25 });
26
27 it("keeps the popover open instead of dropping an over-length draft", () => {
28 expect(
29 resolveAssistantCitationCommentDismissal({
30 reason: "outside-press",
31 draft: "x".repeat(ASSISTANT_CITATION_MAX_COMMENT_LENGTH + 1),
32 savedComment: undefined,
33 }),
34 ).toEqual({ kind: "keep-open" });
35 });
36 });