How to use the jest-prosemirror.td 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-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__ / prosemirror-node-utils.spec.ts View on Github external
it('should return an array if child nodes with the given attribute', () => {
    const { state } = createEditor(
      doc(
        table(
          row(tdEmpty, td({ colspan: 2 } as any, p('2')), td({ colspan: 3 } as any, p('3'))),
          row(td({ colspan: 2 } as any, p('2')), tdEmpty, tdEmpty),
        ),
      ),
    );
    const result = findChildrenByAttr({
      node: state.doc.firstChild,
      predicate: attrs => attrs.colspan === 2,
    });
    expect(result.length).toEqual(2);
    result.forEach(item => {
      expect(item.node.attrs.colspan).toEqual(2);
    });
  });
});
github ifiokjr / remirror / @remirror / core-utils / src / __tests__ / prosemirror-utils.spec.ts View on Github external
it('supports nested leaf nodes', () => {
    const node = atomBlock();
    const {
      state: { selection },
    } = createEditor(doc(p('abcd'), table(row(td(p('1'), node, '')))));
    const position = findPositionOfNodeBefore(selection);
    expect(position).toEqual({ pos: 12, start: 12, end: 13, node });
  });
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 with the given attribute', () => {
    const { state } = createEditor(
      doc(
        table(
          row(tdEmpty, td({ colspan: 2 } as any, p('2')), td({ colspan: 3 } as any, p('3'))),
          row(td({ colspan: 2 } as any, p('2')), tdEmpty, tdEmpty),
        ),
      ),
    );
    const result = findChildrenByAttr({
      node: state.doc.firstChild,
      predicate: attrs => attrs.colspan === 2,
    });
    expect(result.length).toEqual(2);
    result.forEach(item => {
      expect(item.node.attrs.colspan).toEqual(2);
    });
  });
});