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 array if text nodes of a given node', () => {
const { state } = createEditor(doc(table(row(td(p('one', atomInline(), 'two'), td(p('three')))))));
const result = findTextNodes({ node: state.doc.firstChild });
expect(result.length).toEqual(3);
result.forEach(item => {
expect(item.node.isText).toBe(true);
});
});
});
it('should return DOM reference of a paragraph if cursor is inside of a text node', () => {
const { view } = createEditor(doc(p(atomInline(), 'text')));
const ref = findElementAtPosition(3, view);
expect(ref instanceof HTMLParagraphElement).toBe(true);
});
});
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 });
});
it('should return DOM reference of a nested inline leaf node', () => {
const { view } = createEditor(doc(p('one', atomInline(), 'two')));
const ref = findElementAtPosition(4, view);
expect(ref instanceof HTMLSpanElement).toBe(true);
expect(ref.getAttribute('data-node-type')).toEqual('atomInline');
});
it('does not throw error for inserting into leaf node', () => {
const { state, schema } = createEditor(doc(atomInline('')));
expect(canInsertNode(state, schema.nodes.paragraph)).toBeFalse();
});
});