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

Function testPattern

modules/tinymce/src/core/test/ts/browser/ShortcutsTest.ts:79–101  ·  view source on GitHub ↗
(pattern: string, keyCode: number, ctrlKey = false)

Source from the content-addressed store, hash-verified

77 it('Remove', () => {
78 const editor = hook.editor();
79 const testPattern = (pattern: string, keyCode: number, ctrlKey = false) => {
80 let called = false;
81
82 const eventArgs = () => ({
83 ctrlKey,
84 keyCode,
85 altKey: false,
86 shiftKey: false,
87 metaKey: false
88 });
89
90 editor.shortcuts.add(pattern, '', () => {
91 called = true;
92 });
93
94 editor.dispatch('keydown', eventArgs() as KeyboardEvent);
95 assert.isTrue(called, `Shortcut wasn't called when it should have been.`);
96
97 called = false;
98 editor.shortcuts.remove(pattern);
99 editor.dispatch('keydown', eventArgs() as KeyboardEvent);
100 assert.isFalse(called, `Shortcut was called when it shouldn't.`);
101 };
102
103 testPattern('ctrl+d', 68, true);
104 testPattern('ctrl+F2', 113, true);

Callers 1

ShortcutsTest.tsFile · 0.85

Calls 4

eventArgsFunction · 0.85
addMethod · 0.65
dispatchMethod · 0.65
removeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…