Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2
3import {
4 shouldClearTerminalSelectionAction,
5 shouldHandleTerminalExit,
6 terminalSelectionLineRange,
7} from "./ThreadTerminalDrawer";
8
9describe("terminal selection actions", () => {
10 it("clears a pending or currently owned menu when the selection disappears", () => {
11 expect(
12 shouldClearTerminalSelectionAction({
13 actionPending: true,
14 openMenuRequestId: null,
15 currentRequestId: 4,
16 }),
17 ).toBe(true);
18 expect(
19 shouldClearTerminalSelectionAction({
20 actionPending: false,
21 openMenuRequestId: 4,
22 currentRequestId: 4,
23 }),
24 ).toBe(true);
25 });
26
27 it("does not let an old selection popup cancel its replacement right-click menu", () => {
28 expect(
29 shouldClearTerminalSelectionAction({
30 actionPending: false,
31 openMenuRequestId: 3,
32 currentRequestId: 4,
33 }),
34 ).toBe(false);
35 expect(
36 shouldClearTerminalSelectionAction({
37 actionPending: false,
38 openMenuRequestId: null,
39 currentRequestId: 4,
40 }),
41 ).toBe(false);
42 });
43
44 it("uses Ghostty's physical screen range for visually wrapped selections", () => {
45 expect(
46 terminalSelectionLineRange({
47 start: { y: 4 },
48 end: { y: 6 },
49 }),
50 ).toEqual({ lineStart: 5, lineEnd: 7 });
51 });
52
53 it("handles an exit that lands while the terminal surface is still loading", () => {
54 expect(shouldHandleTerminalExit("exited", "running", false)).toBe(true);
55 expect(shouldHandleTerminalExit("exited", "exited", false)).toBe(false);
56 expect(shouldHandleTerminalExit("closed", "running", true)).toBe(false);
57 });
58});