| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { isTerminalLinkActivation, isTerminalUrl } from "./terminal-links"; |
| 4 | |
| 5 | describe("isTerminalUrl", () => { |
| 6 | it("recognizes HTTP schemes without treating workspace paths as URLs", () => { |
| 7 | expect(isTerminalUrl("HTTPS://example.com/docs")).toBe(true); |
| 8 | expect(isTerminalUrl("Http://example.com")).toBe(true); |
| 9 | expect(isTerminalUrl("src/components/main.ts")).toBe(false); |
| 10 | expect(isTerminalUrl("httpsdocs/readme.md")).toBe(false); |
| 11 | }); |
| 12 | }); |
| 13 | |
| 14 | describe("isTerminalLinkActivation", () => { |
| 15 | it("requires cmd on macOS", () => { |
| 16 | expect( |
| 17 | isTerminalLinkActivation( |
| 18 | { |
| 19 | metaKey: true, |
| 20 | ctrlKey: false, |
| 21 | }, |
| 22 | "MacIntel", |
| 23 | ), |
| 24 | ).toBe(true); |
| 25 | expect( |
| 26 | isTerminalLinkActivation( |
| 27 | { |
| 28 | metaKey: false, |
| 29 | ctrlKey: true, |
| 30 | }, |
| 31 | "MacIntel", |
| 32 | ), |
| 33 | ).toBe(false); |
| 34 | }); |
| 35 | |
| 36 | it("requires ctrl on non-macOS", () => { |
| 37 | expect( |
| 38 | isTerminalLinkActivation( |
| 39 | { |
| 40 | metaKey: false, |
| 41 | ctrlKey: true, |
| 42 | }, |
| 43 | "Win32", |
| 44 | ), |
| 45 | ).toBe(true); |
| 46 | expect( |
| 47 | isTerminalLinkActivation( |
| 48 | { |
| 49 | metaKey: true, |
| 50 | ctrlKey: false, |
| 51 | }, |
| 52 | "Linux", |
| 53 | ), |
| 54 | ).toBe(false); |
| 55 | }); |
| 56 | }); |