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 not transform when no match found', () => {
const plugin = markPasteRule({ regexp: /(Hello)/, type: testSchema.marks.strong });
createEditor(doc(p('')), { plugins: [plugin] })
.paste('Not The Word')
.callback(content => {
expect(content.doc).toEqualProsemirrorNode(doc(p('Not The Word')));
});
});
});
test('updateMark', () => {
const from = doc(p('Make bold'));
const to = doc(p('Make ', strong('bold')));
expect(updateMark({ type: schema.marks.strong })).toTransformNode({ from, to });
});
it('should transform simple content', () => {
const plugin = markPasteRule({ regexp: /(Hello)/, type: testSchema.marks.strong });
createEditor(doc(p('')), { plugins: [plugin] })
.paste('Hello')
.callback(content => expect(content.doc).toEqualProsemirrorNode(doc(p(strong('Hello')))));
});
describe('removeMark', () => {
const type = schema.marks.strong;
it('removes the contained mark', () => {
const from = doc(p(strong('bold')));
const to = doc(p('bold'));
expect(removeMark({ type })).toTransformNode({ from, to });
});
it('leaves mark untouched when `expand` is `false`', () => {
const from = doc(p(strong('bold')));
expect(removeMark({ type })).toTransformNode({ from });
});
it('removes mark when `expand` is `true`', () => {
const from = doc(p(strong('bold')));
const to = doc(p('bold'));
expect(removeMark({ type, expand: true })).toTransformNode({ from, to });
});