How to use jest-prosemirror - 10 common examples

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('returns false when selection is active', () => {
    const {
      state: { selection },
    } = createEditor(doc(p('inline'), p('aba', 'awesome')));
    expect(selectionEmpty(selection)).toBeFalse();
  });
github ifiokjr / remirror / @remirror / core-utils / src / __tests__ / dom-utils.spec.ts View on Github external
it('should return false for ambiguous locations', () => {
    const { state } = createEditor(doc(p('Something this  is a word')));
    expect(getSelectedWord(state)).toBeFalse();
  });
github ifiokjr / remirror / @remirror / core-utils / src / __tests__ / dom-utils.spec.ts View on Github external
it('returns false when not within an active region', () => {
    const { state, schema } = createEditor(doc(p('Something', em('is italic'), ' here')));
    expect(isMarkActive({ state, type: schema.marks.em })).toBeFalse();
  });
github ifiokjr / remirror / @remirror / core-utils / src / __tests__ / prosemirror-node-utils.spec.ts View on Github external
it('should return an array if child nodes if a given node has child nodes with the given mark', () => {
    const { state } = createEditor(
      doc(table(row(td(p(strong('one'), 'two')), tdEmpty, td(p('three', strong('four')))))),
    );
    const result = findChildrenByMark({ node: state.doc, type: state.schema.marks.strong });
    expect(result.length).toEqual(2);
    result.forEach(item => {
      expect(item.node.marks[0].type.name).toEqual('strong');
    });
  });
});
github ifiokjr / remirror / @remirror / core-utils / src / __tests__ / dom-utils.spec.ts View on Github external
it('returns an empty object when mark not found', () => {
    const { state, schema } = createEditor(doc(p('a link', em('linked here'))));
    expect(getMarkAttrs(state, schema.marks.link)).toEqual({});
  });
});
github ifiokjr / remirror / @remirror / core-utils / src / __tests__ / dom-utils.spec.ts View on Github external
it('returns true for full selection', () => {
    const { state } = createEditor(doc(p('Something')));
    expect(atDocStart(state)).toBeTrue();
  });
github ifiokjr / remirror / @remirror / core-utils / src / __tests__ / prosemirror-utils.spec.ts View on Github external
it('removes block top level nodes at specified position', () => {
    const {
      state: { tr },
    } = createEditor(doc(p('x'), p('one')));
    const newTr = removeNodeAtPosition({ pos: 3, tr });
    expect(newTr).not.toBe(tr);
    expect(newTr.doc).toEqualProsemirrorNode(doc(p('x')));
  });
github ifiokjr / remirror / @remirror / core-utils / src / __tests__ / prosemirror-utils.spec.ts View on Github external
it('removes nested inline nodes at specified position', () => {
    const {
      state: { tr },
    } = createEditor(doc(p('one', atomInline())));
    const newTr = removeNodeAtPosition({ pos: 4, tr });
    expect(newTr).not.toBe(tr);
    expect(newTr.doc).toEqualProsemirrorNode(doc(p('one')));
  });
});
github ifiokjr / remirror / @remirror / core-utils / src / __tests__ / dom-utils.spec.ts View on Github external
it('returns false when no selection', () => {
    const { state } = createEditor(doc(p('Something')));
    expect(atDocEnd(state)).toBeFalse();
  });
github ifiokjr / remirror / @remirror / core-utils / src / __tests__ / dom-utils.spec.ts View on Github external
it('returns false for a doc with nothing inside', () => {
    expect(isDocNodeEmpty(doc())).toBeFalse();
  });