MCPcopy Index your code
hub / github.com/tinymce/tinymce / assertShortcut

Function assertShortcut

modules/tinymce/src/core/test/ts/browser/ShortcutsTest.ts:21–42  ·  view source on GitHub ↗
(shortcut: string, args: Partial<KeyboardEvent>, assertState: boolean)

Source from the content-addressed store, hash-verified

19 it('Shortcuts formats', () => {
20 const editor = hook.editor();
21 const assertShortcut = (shortcut: string, args: Partial<KeyboardEvent>, assertState: boolean) => {
22 let called = false;
23
24 editor.shortcuts.add(shortcut, '', () => {
25 called = true;
26 });
27
28 args = Tools.extend({
29 ctrlKey: false,
30 altKey: false,
31 shiftKey: false,
32 metaKey: false
33 }, args);
34
35 editor.dispatch('keydown', args as KeyboardEvent);
36
37 if (assertState) {
38 assert.isTrue(called, `Shortcut wasn't called: ` + shortcut);
39 } else {
40 assert.isFalse(called, `Shortcut was called when it shouldn't have been: ` + shortcut);
41 }
42 };
43
44 assertShortcut('ctrl+d', { ctrlKey: true, keyCode: 68 }, true);
45 assertShortcut('ctrl+d', { altKey: true, keyCode: 68 }, false);

Callers 1

ShortcutsTest.tsFile · 0.85

Calls 2

addMethod · 0.65
dispatchMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…