Import AITURK IDE 1.0.0-beta.1 from Hermes 63279301; preserve MIT license
This commit is contained in:
commit
03634b1ca3
11340 files changed
+3442369
No files matched your search
@@ -0,0 +1,64 @@
|
||||
import { render, waitFor } from '@testing-library/react'
|
||||
import { Streamdown } from 'streamdown'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { createMemoizedMathPlugin } from '@/lib/katex-memo'
|
||||
import { normalizeFilePreviewMath } from '@/lib/markdown-preprocess'
|
||||
|
||||
// This is the exact pipeline the file preview runs: normalizeFilePreviewMath
|
||||
// → Streamdown with the memoized math plugin. Rendering here (jsdom) proves the
|
||||
// wiring produces KaTeX output, not raw `$..$` source text.
|
||||
describe('file-preview math rendering', () => {
|
||||
const mathPlugin = createMemoizedMathPlugin({ singleDollarTextMath: true })
|
||||
|
||||
it('renders inline $..$ math as KaTeX', async () => {
|
||||
const { container } = render(
|
||||
<Streamdown mode="static" plugins={{ math: mathPlugin }}>
|
||||
{normalizeFilePreviewMath('The formula $x^2 + y^2$ here.')}
|
||||
</Streamdown>
|
||||
)
|
||||
|
||||
await waitFor(() => {
|
||||
expect(container.querySelector('.katex')).not.toBeNull()
|
||||
})
|
||||
expect(container.textContent).not.toContain('$x^2')
|
||||
})
|
||||
|
||||
it('renders $$..$$ display math as KaTeX', async () => {
|
||||
const { container } = render(
|
||||
<Streamdown mode="static" plugins={{ math: mathPlugin }}>
|
||||
{normalizeFilePreviewMath('Block:\n\n$$E = mc^2$$')}
|
||||
</Streamdown>
|
||||
)
|
||||
|
||||
await waitFor(() => {
|
||||
expect(container.querySelector('.katex-display') || container.querySelector('.katex')).not.toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
it('renders delimited math as KaTeX', async () => {
|
||||
const { container } = render(
|
||||
<Streamdown mode="static" plugins={{ math: mathPlugin }}>
|
||||
{normalizeFilePreviewMath('A fraction \\(\\frac{a}{b}\\) inline.')}
|
||||
</Streamdown>
|
||||
)
|
||||
|
||||
await waitFor(() => {
|
||||
expect(container.querySelector('.katex')).not.toBeNull()
|
||||
})
|
||||
expect(container.querySelector('.katex-mathml, .katex-html')).not.toBeNull()
|
||||
})
|
||||
|
||||
it('leaves a literal code-fence $ alone as code, not math', async () => {
|
||||
const { container } = render(
|
||||
<Streamdown mode="static" plugins={{ math: mathPlugin }}>
|
||||
{normalizeFilePreviewMath('```bash\necho $HOME\n```')}
|
||||
</Streamdown>
|
||||
)
|
||||
|
||||
await waitFor(() => {
|
||||
expect(container.querySelector('.katex')).toBeNull()
|
||||
})
|
||||
expect(container.querySelector('code')?.textContent).toContain('$HOME')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user