fix: invalid DOM element nesting in katex tests

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2023-04-12 18:54:30 +02:00
parent eaea86c17d
commit b763413108
5 changed files with 53 additions and 53 deletions

View file

@ -2,7 +2,7 @@
exports[`katex frame renders a valid latex expression as explicit block 1`] = `
<div>
<div
<p
data-testid="katex-block"
>
<span>
@ -10,21 +10,21 @@ exports[`katex frame renders a valid latex expression as explicit block 1`] = `
</span>
<ul>
<span>
<li>
<span>
tex: \\int_0^\\infty x^2 dx
</li>
</span>
<li>
<span>
block: true
</li>
</span>
</ul>
</div>
</span>
</p>
</div>
`;
@ -38,20 +38,20 @@ exports[`katex frame renders a valid latex expression as explicit inline 1`] = `
</span>
<ul>
<span>
<li>
<span>
tex: \\int_0^\\infty x^2 dx
</li>
</span>
<li>
<span>
block: false
</li>
</span>
</ul>
</span>
</span>
</div>
`;
@ -66,27 +66,27 @@ exports[`katex frame renders a valid latex expression as implicit inline 1`] = `
</span>
<ul>
<span>
<li>
<span>
tex: \\int_0^\\infty x^2 dx
</li>
</span>
<li>
<span>
block: false
</li>
</span>
</ul>
</span>
</span>
</div>
`;
exports[`katex frame renders an error for an invalid latex expression as explicit block 1`] = `
<div>
<div
<p
data-testid="katex-block"
>
<div
@ -95,7 +95,7 @@ exports[`katex frame renders an error for an invalid latex expression as explici
>
mocked parseerror
</div>
</div>
</p>
</div>
`;

View file

@ -2,7 +2,7 @@
exports[`KaTeX markdown extensions renders a valid block LaTeX expression in a single line 1`] = `
<div>
<div
<p
data-testid="katex-block"
>
<span>
@ -10,21 +10,21 @@ exports[`KaTeX markdown extensions renders a valid block LaTeX expression in a s
</span>
<ul>
<span>
<li>
<span>
tex: \\alpha
</li>
</span>
<li>
<span>
block: true
</li>
</span>
</ul>
</div>
</span>
</p>
</div>
@ -32,7 +32,7 @@ exports[`KaTeX markdown extensions renders a valid block LaTeX expression in a s
exports[`KaTeX markdown extensions renders a valid block LaTeX expression in multi line 1`] = `
<div>
<div
<p
data-testid="katex-block"
>
<span>
@ -40,23 +40,23 @@ exports[`KaTeX markdown extensions renders a valid block LaTeX expression in mul
</span>
<ul>
<span>
<li>
<span>
tex:
\\alpha
</li>
</span>
<li>
<span>
block: true
</li>
</span>
</ul>
</div>
</span>
</p>
</div>
@ -73,20 +73,20 @@ exports[`KaTeX markdown extensions renders a valid inline LaTeX expression 1`] =
</span>
<ul>
<span>
<li>
<span>
tex: \\alpha
</li>
</span>
<li>
<span>
block: false
</li>
</span>
</ul>
</span>
</span>
</p>

View file

@ -19,10 +19,10 @@ describe('katex frame', () => {
beforeEach(() => {
jest.spyOn(KatexDefault, 'renderToString').mockImplementation(
(tex: string, options?: KatexOptions) => `<span>This is a mock for lib katex with this parameters:</span>
<ul>
<li>tex: ${tex}</li>
<li>block: ${String(options?.displayMode)}</li>
</ul>`
<span>
<span>tex: ${tex}</span>
<span>block: ${String(options?.displayMode)}</span>
</span>`
)
})

View file

@ -40,7 +40,7 @@ export const KatexFrame: React.FC<KatexFrameProps> = ({ expression, block = fals
}
}, [block, expression])
return block ? <div {...testId('katex-block')}>{dom}</div> : <span {...testId('katex-inline')}>{dom}</span>
return block ? <p {...testId('katex-block')}>{dom}</p> : <span {...testId('katex-inline')}>{dom}</span>
}
export default KatexFrame

View file

@ -21,10 +21,10 @@ describe('KaTeX markdown extensions', () => {
beforeEach(() => {
jest.spyOn(KatexDefault, 'renderToString').mockImplementation(
(tex: string, options?: KatexOptions) => `<span>This is a mock for lib katex with this parameters:</span>
<ul>
<li>tex: ${tex}</li>
<li>block: ${String(options?.displayMode)}</li>
</ul>`
<span>
<span>tex: ${tex}</span>
<span>block: ${String(options?.displayMode)}</span>
</span>`
)
})