(pattern: string, keyCode: number, ctrlKey = false)
| 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); |
no test coverage detected
searching dependent graphs…