Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should return an empty array if a given node does not have text nodes', () => {
const { state } = createEditor(doc(table(row(tdEmpty))));
const result = findTextNodes({ node: state.doc.firstChild });
expect(result.length).toEqual(0);
});
it('should return an array if child nodes of a given `nodeType`', () => {
const { state } = createEditor(doc(table(row(tdEmpty, tdEmpty, tdEmpty))));
const result = findChildrenByNode({ node: state.doc, type: state.schema.nodes.table_cell });
expect(result.length).toEqual(3);
result.forEach(item => {
expect(item.node.type.name).toEqual('table_cell');
});
});
});
it('should return an array if block nodes of a given node', () => {
const { state } = createEditor(doc(table(row(tdEmpty, tdEmpty))));
const result = findBlockNodes({ node: state.doc.firstChild });
expect(result.length).toEqual(5);
result.forEach(item => {
expect(item.node.isBlock).toBe(true);
});
});
});