Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('removes block top level nodes at specified position', () => {
const {
state: { tr },
} = createEditor(doc(p('x'), p('one')));
const newTr = removeNodeAtPosition({ pos: 3, tr });
expect(newTr).not.toBe(tr);
expect(newTr.doc).toEqualProsemirrorNode(doc(p('x')));
});
it('returns false for a doc with nothing inside', () => {
expect(isDocNodeEmpty(doc())).toBeFalse();
});
it('toggles to the specified type', () => {
const from = doc(p('toggled'));
const to = doc(h1('toggled'));
expect(
toggleBlockItem({
type: schema.nodes.heading,
toggleType: schema.nodes.paragraph,
attrs: { level: 1 },
}),
).toTransformNode({
from,
to,
});
});
it('toggles to the specified list type', () => {
const from = doc(p('make list'));
const to = doc(ul(li(p('make list'))));
expect(toggleList(schema.nodes.bulletList, schema.nodes.listItem)).toTransformNode({
from,
to,
});
});
});
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('supports non-nested leaf nodes', () => {
const node = atomBlock();
const {
state: { selection },
} = createEditor(doc(p('abcd'), node, ''));
const position = findPositionOfNodeBefore(selection);
expect(position).toEqual({ pos: 6, start: 6, end: 7, node });
});
.callback(content => {
expect(content.doc).toEqualProsemirrorNode(
doc(
p('Some ', strong('@test'), ' ', strong('@content')),
p('should ', strong('@be'), ' amazing'),
p(''),
),
);
});
});