Files
t3code/apps/web/src/components/diffs/commentSubmitShortcut.test.ts
T
cad2c93616 feat: multi-provider pull requests page with in-app reviews (#4849)
Co-authored-by: Julius Marminge <[email protected]>
Co-authored-by: Claude Fable 5 <[email protected]>
Co-authored-by: maria <[email protected]>
Co-authored-by: maria-rcks <[email protected]>
Co-authored-by: codex <[email protected]>
2026-08-10 17:47:02 +02:00

27 lines
981 B
TypeScript

import { describe, expect, it } from "vite-plus/test";
import { isCommentSubmitShortcut } from "./commentSubmitShortcut";
describe("isCommentSubmitShortcut", () => {
it("accepts Command or Ctrl+Enter only while an eligible comment is idle", () => {
expect(
isCommentSubmitShortcut({ key: "Enter", metaKey: true, ctrlKey: false }, "Looks good", false),
).toBe(true);
expect(
isCommentSubmitShortcut({ key: "Enter", metaKey: false, ctrlKey: true }, "Looks good", false),
).toBe(true);
expect(
isCommentSubmitShortcut({ key: "Enter", metaKey: true, ctrlKey: false }, "Looks good", true),
).toBe(false);
});
it("rejects empty comments and unrelated key presses", () => {
expect(
isCommentSubmitShortcut({ key: "Enter", metaKey: true, ctrlKey: false }, " ", false),
).toBe(false);
expect(
isCommentSubmitShortcut({ key: "K", metaKey: true, ctrlKey: false }, "Looks good", false),
).toBe(false);
});
});