| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { isCommentSubmitShortcut } from "./commentSubmitShortcut"; |
| 4 | |
| 5 | describe("isCommentSubmitShortcut", () => { |
| 6 | it("accepts Command or Ctrl+Enter only while an eligible comment is idle", () => { |
| 7 | expect( |
| 8 | isCommentSubmitShortcut({ key: "Enter", metaKey: true, ctrlKey: false }, "Looks good", false), |
| 9 | ).toBe(true); |
| 10 | expect( |
| 11 | isCommentSubmitShortcut({ key: "Enter", metaKey: false, ctrlKey: true }, "Looks good", false), |
| 12 | ).toBe(true); |
| 13 | expect( |
| 14 | isCommentSubmitShortcut({ key: "Enter", metaKey: true, ctrlKey: false }, "Looks good", true), |
| 15 | ).toBe(false); |
| 16 | }); |
| 17 | |
| 18 | it("rejects empty comments and unrelated key presses", () => { |
| 19 | expect( |
| 20 | isCommentSubmitShortcut({ key: "Enter", metaKey: true, ctrlKey: false }, " ", false), |
| 21 | ).toBe(false); |
| 22 | expect( |
| 23 | isCommentSubmitShortcut({ key: "K", metaKey: true, ctrlKey: false }, "Looks good", false), |
| 24 | ).toBe(false); |
| 25 | }); |
| 26 | }); |