(shortcut: string, args: Partial<KeyboardEvent>, assertState: boolean)
| 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); |
no test coverage detected
searching dependent graphs…