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

View file

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

View file

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

View file

@ -40,7 +40,7 @@ export const KatexFrame: React.FC<KatexFrameProps> = ({ expression, block = fals
} }
}, [block, expression]) }, [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 export default KatexFrame

View file

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