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 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('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('is false when from and to specified in empty node', () => {
const { state, schema } = createEditor(doc(p(em('is italic')), p('')));
expect(isMarkActive({ state, type: schema.marks.em, from: 11, to: 20 })).toBeFalse();
});
});
it('returns false with no selection', () => {
const { state, schema } = createEditor(doc(p(' ', em('italic'))));
expect(isMarkActive({ state, type: schema.marks.em })).toBeFalse();
});
it('only returns true when $pos starts within mark', () => {
const { state, schema } = createEditor(doc(p('Something', em('is italic'))));
expect(getMarkRange(state.selection.$from, schema.marks.em)).toBeFalse();
});
});
it('returns false for non-prosemirror nodes', () => {
expect(isProsemirrorNode(em())).toBeFalse();
});
});
it('shows active when within an active region', () => {
const { state, schema } = createEditor(doc(p('Something', em('is italic'), ' here')));
expect(isMarkActive({ state, type: schema.marks.em })).toBeTrue();
});