import { describe, expect, it } from "vite-plus/test"; import { shouldClearTerminalSelectionAction, shouldHandleTerminalExit, terminalSelectionLineRange, } from "./ThreadTerminalDrawer"; describe("terminal selection actions", () => { it("clears a pending or currently owned menu when the selection disappears", () => { expect( shouldClearTerminalSelectionAction({ actionPending: true, openMenuRequestId: null, currentRequestId: 4, }), ).toBe(true); expect( shouldClearTerminalSelectionAction({ actionPending: false, openMenuRequestId: 4, currentRequestId: 4, }), ).toBe(true); }); it("does not let an old selection popup cancel its replacement right-click menu", () => { expect( shouldClearTerminalSelectionAction({ actionPending: false, openMenuRequestId: 3, currentRequestId: 4, }), ).toBe(false); expect( shouldClearTerminalSelectionAction({ actionPending: false, openMenuRequestId: null, currentRequestId: 4, }), ).toBe(false); }); it("uses Ghostty's physical screen range for visually wrapped selections", () => { expect( terminalSelectionLineRange({ start: { y: 4 }, end: { y: 6 }, }), ).toEqual({ lineStart: 5, lineEnd: 7 }); }); it("handles an exit that lands while the terminal surface is still loading", () => { expect(shouldHandleTerminalExit("exited", "running", false)).toBe(true); expect(shouldHandleTerminalExit("exited", "exited", false)).toBe(false); expect(shouldHandleTerminalExit("closed", "running", true)).toBe(false); }); });