Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('returns false when selection is active', () => {
const {
state: { selection },
} = createEditor(doc(p('inline'), p('aba', 'awesome')));
expect(selectionEmpty(selection)).toBeFalse();
});
it('should return false for ambiguous locations', () => {
const { state } = createEditor(doc(p('Something this is a word')));
expect(getSelectedWord(state)).toBeFalse();
});
it('returns false when not within an active region', () => {
const { state, schema } = createEditor(doc(p('Something', em('is italic'), ' here')));
expect(isMarkActive({ state, type: schema.marks.em })).toBeFalse();
});
it('should return an array if child nodes if a given node has child nodes with the given mark', () => {
const { state } = createEditor(
doc(table(row(td(p(strong('one'), 'two')), tdEmpty, td(p('three', strong('four')))))),
);
const result = findChildrenByMark({ node: state.doc, type: state.schema.marks.strong });
expect(result.length).toEqual(2);
result.forEach(item => {
expect(item.node.marks[0].type.name).toEqual('strong');
});
});
});
it('returns an empty object when mark not found', () => {
const { state, schema } = createEditor(doc(p('a link', em('linked here'))));
expect(getMarkAttrs(state, schema.marks.link)).toEqual({});
});
});
it('returns true for full selection', () => {
const { state } = createEditor(doc(p('Something')));
expect(atDocStart(state)).toBeTrue();
});
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('removes nested inline nodes at specified position', () => {
const {
state: { tr },
} = createEditor(doc(p('one', atomInline())));
const newTr = removeNodeAtPosition({ pos: 4, tr });
expect(newTr).not.toBe(tr);
expect(newTr.doc).toEqualProsemirrorNode(doc(p('one')));
});
});
it('returns false when no selection', () => {
const { state } = createEditor(doc(p('Something')));
expect(atDocEnd(state)).toBeFalse();
});
it('returns false for a doc with nothing inside', () => {
expect(isDocNodeEmpty(doc())).toBeFalse();
});