Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

AnnotationKeyboard.test.ts

22 lines766 Bytes

1import { describe, expect, it } from "vite-plus/test";
2​
3import { resolveAnnotationSubmission } from "./AnnotationKeyboard.ts";
4​
5const keyboardEvent = (
6 overrides: Partial<Parameters<typeof resolveAnnotationSubmission>[0]> = {},
7) => ({
8 key: "Enter",
9 metaKey: false,
10 ctrlKey: false,
11 shiftKey: false,
12 isComposing: false,
13 ...overrides,
14});
15​
16describe("resolveAnnotationSubmission", () => {
17 it("leaves Shift+Enter and composition events available for editing", () => {
18 expect(resolveAnnotationSubmission(keyboardEvent({ shiftKey: true }), true)).toBeNull();
19 expect(resolveAnnotationSubmission(keyboardEvent({ isComposing: true }), true)).toBeNull();
20 expect(resolveAnnotationSubmission(keyboardEvent({ key: " " }), true)).toBeNull();
21 });
22});