How to use the jest-prosemirror.horizontalRule function in jest-prosemirror

To help you get started, we’ve selected a few jest-prosemirror examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ifiokjr / remirror / @remirror / core-utils / src / __tests__ / prosemirror-rules.spec.ts View on Github external
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']));
  });