How to use the jest-prosemirror.table 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 of matched nodes `predicate` returns truthy for', () => {
    const { state } = createEditor(doc(table(row(tdEmpty), row(tdEmpty), row(tdEmpty))));
    const result = findChildren({
      node: state.doc.firstChild,
      predicate: node => node.type === state.schema.nodes.paragraph,
    });
    expect(result.length).toEqual(3);
    result.forEach(item => {
      expect(item.node.type.name).toEqual('paragraph');
    });
  });
  it('should return an empty array if `predicate` returns falsy', () => {
github ifiokjr / remirror / @remirror / core-utils / src / __tests__ / prosemirror-utils.spec.ts View on Github external
it('returns `undefined` when no parent node found', () => {
    const {
      state: { selection },
    } = createEditor(doc(table(row(tdCursor))));
    const result = findParentNode({
      predicate: pmNode => pmNode.type === schema.nodes.table_header,
      selection,
    });
    expect(result).toBeUndefined();
  });
});
github ifiokjr / remirror / @remirror / core-utils / src / __tests__ / prosemirror-utils.spec.ts View on Github external
it('supports removing tables', () => {
    const {
      state: { tr },
    } = createEditor(doc(p('one'), table(row(tdEmpty), row(tdEmpty)), '', p('two')));
    const newTr = removeNodeBefore(tr);
    expect(newTr).not.toBe(tr);
    expect(newTr.doc).toEqualProsemirrorNode(doc(p('one'), p('two')));
  });
github ifiokjr / remirror / @remirror / core-utils / src / __tests__ / dom-utils.spec.ts View on Github external
it('returns true when it successfully matches', () => {
    expect(nodeNameMatchesList(p(), matchers)).toBeTrue();
    expect(nodeNameMatchesList(blockquote(), matchers)).toBeTrue();
    expect(nodeNameMatchesList(table(), matchers)).toBeTrue();
  });
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 tables', () => {
    const node = table(row(tdEmpty), row(tdEmpty));
    const {
      state: { selection },
    } = createEditor(doc(p('abcd'), node, ''));
    const result = findPositionOfNodeBefore(selection);
    expect(result).toEqual({ pos: 6, start: 7, end: 20, node });
  });