Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const shortcuts = Heading.config.addKeyboardShortcuts.call(Heading);
const [firstShortcut] = Object.keys(shortcuts);
const nodeName = Heading.name;
editor.chain().keyboardShortcut(firstShortcut).insertContent(HEADING_TEXT).run();
expect(trackingSpy).toHaveBeenCalledWith(undefined, KEYBOARD_SHORTCUT_TRACKING_ACTION, {
label: CONTENT_EDITOR_TRACKING_LABEL,
property: `${nodeName}.${firstShortcut}`,
});
});
});
it.each`
extension | shortcut
${ListItem.name} | ${ENTER_KEY}
${CodeBlockLowlight.name} | ${BACKSPACE_KEY}
`('does not track $shortcut shortcut for $extension extension', ({ shortcut }) => {
editor.chain().keyboardShortcut(shortcut).run();
expect(trackingSpy).not.toHaveBeenCalled();
});
describe('when creating a heading using an input rule', () => {
it('sends a tracking event indicating that a heading was created using an input rule', async () => {
const nodeName = Heading.name;
const { view } = editor;
const { selection } = view.state;
// Triggers the event handler that input rules listen to
view.someProp('handleTextInput', (f) => f(view, selection.from, selection.to, '## '));