2021-10-14 09:09:30 +00:00
|
|
|
import MathInline from '~/content_editor/extensions/math_inline';
|
2021-10-22 09:09:20 +00:00
|
|
|
import { createTestEditor, createDocBuilder, triggerMarkInputRule } from '../test_utils';
|
2021-10-14 09:09:30 +00:00
|
|
|
|
|
|
|
describe('content_editor/extensions/math_inline', () => {
|
|
|
|
let tiptapEditor;
|
|
|
|
let doc;
|
|
|
|
let p;
|
|
|
|
let mathInline;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
tiptapEditor = createTestEditor({ extensions: [MathInline] });
|
|
|
|
|
|
|
|
({
|
|
|
|
builders: { doc, p, mathInline },
|
|
|
|
} = createDocBuilder({
|
|
|
|
tiptapEditor,
|
|
|
|
names: {
|
|
|
|
details: { markType: MathInline.name },
|
|
|
|
},
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
|
|
|
|
it.each`
|
|
|
|
input | insertedNode
|
|
|
|
${'$`a^2`$'} | ${() => p(mathInline('a^2'))}
|
|
|
|
${'$`a^2`'} | ${() => p('$`a^2`')}
|
|
|
|
${'`a^2`$'} | ${() => p('`a^2`$')}
|
|
|
|
`('with input=$input, then should insert a $insertedNode', ({ input, insertedNode }) => {
|
|
|
|
const expectedDoc = doc(insertedNode());
|
|
|
|
|
2021-10-22 09:09:20 +00:00
|
|
|
triggerMarkInputRule({ tiptapEditor, inputRuleText: input });
|
2021-10-14 09:09:30 +00:00
|
|
|
|
|
|
|
expect(tiptapEditor.getJSON()).toEqual(expectedDoc.toJSON());
|
|
|
|
});
|
|
|
|
});
|