Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should wrap matched content with the specified node type', () => {
const getAttrs = jest.fn(() => ({ 'data-testid': 'awesome' }));
const rule = nodeInputRule({ regexp: /~([^~]+)~$/, type: testSchema.nodes.horizontalRule, getAttrs });
const {
state: { selection },
view,
} = createEditor(doc(p('~Hello')), { rules: [rule] });
const { from, to } = selection;
const params = [view, from, to, '~'];
view.someProp('handleTextInput', f => {
f(...params);
});
expect(view.state.doc).toEqualProsemirrorNode(doc(horizontalRule(), p()));
expect(getAttrs).toHaveBeenCalledWith(expect.arrayContaining(['~Hello~', 'Hello']));
});