Skip to content

Commit 4aaeb88

Browse files
committed
test(Code): add test to check inline code overlapping
1 parent b4f9ae0 commit 4aaeb88

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/extensions/markdown/Code/Code.test.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,22 @@ import {builders} from 'prosemirror-test-builder';
22
import {createMarkupChecker} from '../../../../tests/sameMarkup';
33
import {ExtensionsManager} from '../../../core';
44
import {BaseNode, BaseSchema} from '../../base/BaseSchema';
5+
import {bold, Bold} from '../Bold';
6+
import {italic, Italic} from '../Italic';
57
import {code, Code} from './index';
68

79
const {schema, parser, serializer} = new ExtensionsManager({
8-
extensions: (builder) => builder.use(BaseSchema, {}).use(Code, {}),
10+
extensions: (builder) =>
11+
builder.use(BaseSchema, {}).use(Bold, {}).use(Code, {}).use(Italic, {}),
912
}).buildDeps();
1013

11-
const {doc, p, c} = builders(schema, {
14+
const {doc, p, b, i, c} = builders(schema, {
1215
doc: {nodeType: BaseNode.Doc},
1316
p: {nodeType: BaseNode.Paragraph},
17+
b: {nodeType: bold},
18+
i: {nodeType: italic},
1419
c: {nodeType: code},
15-
}) as PMTestBuilderResult<'doc' | 'p', 'c'>;
20+
}) as PMTestBuilderResult<'doc' | 'p', 'b' | 'i' | 'c'>;
1621

1722
const {same} = createMarkupChecker({parser, serializer});
1823

@@ -21,4 +26,10 @@ describe('Code extension', () => {
2126

2227
it('should parse code inside text', () =>
2328
same('he`llo wor`ld!', doc(p('he', c('llo wor'), 'ld!'))));
29+
30+
it('should parse and serialize overlapping inline marks', () =>
31+
same(
32+
'This is **strong *emphasized text with `code` in* it**',
33+
doc(p('This is ', b('strong ', i('emphasized text with ', c('code'), ' in'), ' it'))),
34+
));
2435
});

0 commit comments

Comments
 (0)