Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('supports blockquotes', () => {
const node = blockquote(p(''));
const {
state: { selection },
} = createEditor(doc(p('abcd'), node, ''));
const position = findPositionOfNodeBefore(selection);
expect(position).toEqual({ pos: 6, start: 7, end: 10, node });
});
it('returns false with text selection surrounds the node', () => {
const { state, schema: sch } = createEditor(
doc(p('Something', blockquote('is italic'), ' here')),
);
expect(isNodeActive({ state, type: sch.nodes.blockquote })).toBeFalse();
});
it('returns false when not within the node', () => {
const { state, schema: sch } = createEditor(doc(p('Something', blockquote('hello'))));
expect(isNodeActive({ state, type: sch.nodes.blockquote })).toBeFalse();
});
it('returns true when node selection directly before node', () => {
const { state, schema: sch } = createEditor(doc(p('Something', blockquote('is italic'), 'here')));
expect(isNodeActive({ state, type: sch.nodes.blockquote })).toBeTrue();
});
it('shows active when within an active region', () => {
const { state, schema: sch } = createEditor(doc(p('Something', blockquote('is in blockquote'))));
expect(isNodeActive({ state, type: sch.nodes.blockquote })).toBeTrue();
});
it('lifts the node when already wrapped', () => {
const from = doc(p(blockquote('Lift me')));
const to = doc(blockquote('Lift me'));
expect(toggleWrap(schema.nodes.blockquote)).toTransformNode({ from, to });
});
});
it('matches with an array of nodeTypes', () => {
const { paragraph, blockquote: bq } = schema.nodes;
expect(nodeEqualsType({ types: [paragraph, bq], node: blockquote() })).toBeTrue();
});
});
it('returns true when it successfully matches', () => {
expect(nodeNameMatchesList(p(), matchers)).toBeTrue();
expect(nodeNameMatchesList(blockquote(), matchers)).toBeTrue();
expect(nodeNameMatchesList(table(), matchers)).toBeTrue();
});
it('returns false nested within other nodes', () => {
const { state, schema: sch } = createEditor(doc(p('a', p(p(blockquote('is italic')), 'here'))));
expect(isNodeActive({ state, type: sch.nodes.blockquote })).toBeFalse();
});
it('should return DOM reference of a content block node', () => {
const { view } = createEditor(doc(p('one'), blockquote(p('two'))));
const ref = findElementAtPosition(5, view);
expect(ref instanceof HTMLQuoteElement).toBe(true);
});