mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 02:18:08 +08:00
test: improve coverage parameters for some files in base (#33207)
This commit is contained in:
@ -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>
|
||||
}
|
||||
},
|
||||
}))
|
||||
|
||||
|
||||
@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user