How to use the jest-prosemirror.schema.nodes 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-utils.spec.ts View on Github external
it('matches with a singular nodeType', () => {
    expect(nodeEqualsType({ types: schema.nodes.paragraph, node: p() })).toBeTrue();
  });
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']));
  });
github ifiokjr / remirror / @remirror / core-utils / src / __tests__ / prosemirror-utils.spec.ts View on Github external
it('matches with an array of nodeTypes', () => {
    const { paragraph, blockquote: bq } = schema.nodes;
    expect(nodeEqualsType({ types: [paragraph, bq], node: blockquote() })).toBeTrue();
  });
});
github ifiokjr / remirror / @remirror / core-utils / src / __tests__ / prosemirror-rules.spec.ts View on Github external
it('should not give false positives', () => {
    const rule = nodeInputRule({ regexp: /~([^~]+)~$/, type: testSchema.nodes.horizontalRule });
    const {
      state: { selection },
      view,
    } = createEditor(doc(p('~Hello')), { rules: [rule] });
    const { from, to } = selection;
    const params = [view, from, to, '@'];
    view.someProp('handleTextInput', f => {
      const value = f(...params);
      expect(value).toBe(false);
      return value;
    });

    expect(view.state.doc).toEqualProsemirrorNode(doc(p('~Hello')));
  });
});
github ifiokjr / remirror / @remirror / core-utils / src / __tests__ / command-utils.spec.ts View on Github external
it('adds the node wrapping the selection', () => {
    const from = doc(p('Wrap ', 'me'));
    const to = doc(blockquote(p('Wrap me')));
    expect(toggleWrap(schema.nodes.blockquote)).toTransformNode({ from, to });
  });
github ifiokjr / remirror / @remirror / core-utils / src / __tests__ / command-utils.spec.ts View on Github external
it('replaces valid content', () => {
    const from = doc(p('replace me'));
    const to = doc(p('replace ', atomInline()));
    expect(replaceText({ appendText: '', type: schema.nodes.atomInline })).toTransformNode({ from, to });
  });