test: improve coverage parameters for some files in base (#33207)

This commit is contained in:
Saumya Talwani
2026-03-12 12:27:31 +05:30
committed by GitHub
parent c43307dae1
commit 68982f910e
86 changed files with 7513 additions and 765 deletions

View File

@ -7,10 +7,17 @@ const { mockReactMarkdownWrapper } = vi.hoisted(() => ({
mockReactMarkdownWrapper: vi.fn(),
}))
vi.mock('../react-markdown-wrapper', () => ({
ReactMarkdownWrapper: () => null,
}))
vi.mock('next/dynamic', () => ({
default: () => (props: { latexContent: string }) => {
mockReactMarkdownWrapper(props)
return <div data-testid="react-markdown-wrapper">{props.latexContent}</div>
default: (loader: () => Promise<unknown>) => {
void loader()
return (props: { latexContent: string }) => {
mockReactMarkdownWrapper(props)
return <div data-testid="react-markdown-wrapper">{props.latexContent}</div>
}
},
}))

View File

@ -30,6 +30,12 @@ describe('preprocessLaTeX', () => {
expect(out).toContain('$$x^2 + 1$$')
})
it('converts multiline \\[ ... \\] blocks into $$ ... $$', () => {
const input = 'Block:\n\\[\na+b=c\n\\]'
const out = mod.preprocessLaTeX(input)
expect(out).toContain('$$\na+b=c\n$$')
})
it('converts \\( ... \\) into $$ ... $$', () => {
const input = 'Inline: \\(a+b\\)'
const out = mod.preprocessLaTeX(input)
@ -91,6 +97,14 @@ describe('preprocessThinkTag', () => {
const endCount = (out.match(/\[ENDTHINKFLAG\]<\/details>/g) || []).length
expect(endCount).toBe(2)
})
it('normalizes repeated think tags to a single details pair', () => {
const input = '<think><think>deep</think></think>'
const out = mod.preprocessThinkTag(input)
expect((out.match(/<details data-think=true>/g) || []).length).toBe(1)
expect((out.match(/\[ENDTHINKFLAG\]<\/details>/g) || []).length).toBe(1)
})
})
describe('customUrlTransform', () => {