The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 03:37 UTC
| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { resolveAnnotationSubmission } from "./AnnotationKeyboard.ts"; |
| 4 | |
| 5 | const keyboardEvent = ( |
| 6 | overrides: Partial<Parameters<typeof resolveAnnotationSubmission>[0]> = {}, |
| 7 | ) => ({ |
| 8 | isTrusted: true, |
| 9 | key: "Enter", |
| 10 | metaKey: false, |
| 11 | ctrlKey: false, |
| 12 | shiftKey: false, |
| 13 | isComposing: false, |
| 14 | ...overrides, |
| 15 | }); |
| 16 | |
| 17 | describe("resolveAnnotationSubmission", () => { |
| 18 | it("requires trusted input to attach or send an annotation", () => { |
| 19 | expect(resolveAnnotationSubmission(keyboardEvent(), true)).toBe("attach"); |
| 20 | expect(resolveAnnotationSubmission(keyboardEvent({ metaKey: true }), true)).toBe("send"); |
| 21 | expect(resolveAnnotationSubmission(keyboardEvent({ isTrusted: false }), true)).toBeNull(); |
| 22 | expect( |
| 23 | resolveAnnotationSubmission(keyboardEvent({ isTrusted: false, metaKey: true }), true), |
| 24 | ).toBeNull(); |
| 25 | }); |
| 26 | it("leaves Shift+Enter and composition events available for editing", () => { |
| 27 | expect(resolveAnnotationSubmission(keyboardEvent({ shiftKey: true }), true)).toBeNull(); |
| 28 | expect(resolveAnnotationSubmission(keyboardEvent({ isComposing: true }), true)).toBeNull(); |
| 29 | expect(resolveAnnotationSubmission(keyboardEvent({ key: " " }), true)).toBeNull(); |
| 30 | }); |
| 31 | }); |