blob: abf10317b5a143bbab91e6b3e0075c7faa5c9de4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
import MathInline from '~/content_editor/extensions/math_inline';
import { createTestEditor, createDocBuilder, triggerMarkInputRule } from '../test_utils';
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());
triggerMarkInputRule({ tiptapEditor, inputRuleText: input });
expect(tiptapEditor.getJSON()).toEqual(expectedDoc.toJSON());
});
});
|