test(ui-primitives): cover the fence pre-routing arms; drop the unreachable array probe
CI coverage flagged MarkdownText's pre route: the array-element probe (raw[0]) and the mixed-content fallbacks were unreachable — the markdown pipeline hands pre one code element whose children are one string (or none, for an empty fence). Simplify to the string check, annotate the isValidElement guard as representation-change armor, and pin both live arms: the empty fence keeps the stock <pre>, a language-less fence renders the plain CodeBlock arm.
This commit is contained in:
@@ -64,6 +64,15 @@ describe('MarkdownText', () => {
|
||||
expect(screen.getByRole('link', { name: 'https://deepseek.com' })).toBeTruthy()
|
||||
})
|
||||
|
||||
it('an empty fence keeps the stock pre; a language-less fence renders the plain CodeBlock arm', () => {
|
||||
const empty = render(<MarkdownText text={'```\n```'} />)
|
||||
expect(empty.container.querySelector('pre')?.outerHTML).toBe('<pre><code></code></pre>')
|
||||
|
||||
const plain = render(<MarkdownText text={'```\nno language here\n```'} />)
|
||||
expect(plain.container.querySelector('pre.shiki')).toBeNull()
|
||||
expect(plain.container.querySelector('pre code')?.textContent).toContain('no language here')
|
||||
})
|
||||
|
||||
it('streaming renders fences plain; the finalize swap highlights them', () => {
|
||||
const fence = '```ts\nconst answer = 42\n```'
|
||||
const live = render(<MarkdownText text={fence} streaming />)
|
||||
|
||||
Reference in New Issue
Block a user