mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-13 06:34:39 -04:00
fix: unsupported tag name in markdown-to-react.spec.tsx
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
8402ef13f3
commit
2abc697e6a
5 changed files with 6 additions and 8 deletions
|
@ -57,9 +57,9 @@ exports[`markdown to react will use markdown render extensions 1`] = `
|
||||||
data-native="true"
|
data-native="true"
|
||||||
>
|
>
|
||||||
|
|
||||||
<nodeprocessor>
|
<node-processor>
|
||||||
node processor children
|
node processor children
|
||||||
</nodeprocessor>
|
</node-processor>
|
||||||
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
import { MarkdownToReact } from './markdown-to-react'
|
import { MarkdownToReact } from './markdown-to-react'
|
||||||
import { TestMarkdownRendererExtension } from './test-utils/test-markdown-renderer-extension'
|
import { TestMarkdownRendererExtension } from './test-utils/test-markdown-renderer-extension'
|
||||||
import { render } from '@testing-library/react'
|
import { render } from '@testing-library/react'
|
||||||
import type { EventMap } from 'eventemitter2'
|
|
||||||
import { EventEmitter2 } from 'eventemitter2'
|
|
||||||
|
|
||||||
describe('markdown to react', () => {
|
describe('markdown to react', () => {
|
||||||
it('can render markdown with newlines as line breaks', () => {
|
it('can render markdown with newlines as line breaks', () => {
|
||||||
|
@ -60,7 +58,7 @@ describe('markdown to react', () => {
|
||||||
const view = render(
|
const view = render(
|
||||||
<MarkdownToReact
|
<MarkdownToReact
|
||||||
markdownContentLines={['<span>test</span>']}
|
markdownContentLines={['<span>test</span>']}
|
||||||
markdownRenderExtensions={[new TestMarkdownRendererExtension(new EventEmitter2<EventMap>())]}
|
markdownRenderExtensions={[new TestMarkdownRendererExtension()]}
|
||||||
newlinesAreBreaks={true}
|
newlinesAreBreaks={true}
|
||||||
allowHtml={false}
|
allowHtml={false}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -28,7 +28,7 @@ export class TestMarkdownRendererExtension extends MarkdownRendererExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTagNameAllowList(): string[] {
|
buildTagNameAllowList(): string[] {
|
||||||
return ['nodeProcessor']
|
return ['node-processor']
|
||||||
}
|
}
|
||||||
|
|
||||||
configureMarkdownItPost(markdownIt: MarkdownIt) {
|
configureMarkdownItPost(markdownIt: MarkdownIt) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { Element, Text } from 'domhandler'
|
||||||
|
|
||||||
export class TestNodeProcessor extends NodeProcessor {
|
export class TestNodeProcessor extends NodeProcessor {
|
||||||
process(document: Document): Document {
|
process(document: Document): Document {
|
||||||
document.childNodes.push(new Element('nodeProcessor', {}, [new Text('node processor children')]))
|
document.childNodes.push(new Element('node-processor', {}, [new Text('node processor children')]))
|
||||||
return document
|
return document
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import React, { Fragment } from 'react'
|
||||||
|
|
||||||
export class TestReplacer extends ComponentReplacer {
|
export class TestReplacer extends ComponentReplacer {
|
||||||
replace(node: Element, subNodeTransform: SubNodeTransform, nativeRenderer: NativeRenderer): NodeReplacement {
|
replace(node: Element, subNodeTransform: SubNodeTransform, nativeRenderer: NativeRenderer): NodeReplacement {
|
||||||
return node.tagName === 'nodeProcessor' ? (
|
return node.tagName === 'node-processor' ? (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<span>NodeProcessor! </span>
|
<span>NodeProcessor! </span>
|
||||||
<span data-children={true}> {node.childNodes.map(subNodeTransform)} </span>
|
<span data-children={true}> {node.childNodes.map(subNodeTransform)} </span>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue