diff options
Diffstat (limited to 'packages/excalidraw/tests/shortcuts.test.tsx')
| -rw-r--r-- | packages/excalidraw/tests/shortcuts.test.tsx | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/packages/excalidraw/tests/shortcuts.test.tsx b/packages/excalidraw/tests/shortcuts.test.tsx new file mode 100644 index 0000000..e02ed01 --- /dev/null +++ b/packages/excalidraw/tests/shortcuts.test.tsx @@ -0,0 +1,31 @@ +import React from "react"; +import { KEYS } from "../keys"; +import { Excalidraw } from "../index"; +import { API } from "./helpers/api"; +import { Keyboard } from "./helpers/ui"; +import { fireEvent, render, waitFor } from "./test-utils"; + +describe("shortcuts", () => { + it("Clear canvas shortcut should display confirm dialog", async () => { + await render( + <Excalidraw + initialData={{ elements: [API.createElement({ type: "rectangle" })] }} + handleKeyboardGlobally + />, + ); + + expect(window.h.elements.length).toBe(1); + + Keyboard.withModifierKeys({ ctrl: true }, () => { + Keyboard.keyDown(KEYS.DELETE); + }); + const confirmDialog = document.querySelector(".confirm-dialog")!; + expect(confirmDialog).not.toBe(null); + + fireEvent.click(confirmDialog.querySelector('[aria-label="Confirm"]')!); + + await waitFor(() => { + expect(window.h.elements[0].isDeleted).toBe(true); + }); + }); +}); |
