chore: uptick
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { preprocessMarkdown } from './markdown-text'
|
||||
|
||||
describe('preprocessMarkdown', () => {
|
||||
it('strips inline accidental triple-backtick starts', () => {
|
||||
const input = [
|
||||
'Working as intended.',
|
||||
"Here's your scene: ``` http://localhost:8812/",
|
||||
'',
|
||||
'- **Multicolored cube**',
|
||||
'- **Rotates**'
|
||||
].join('\n')
|
||||
|
||||
const output = preprocessMarkdown(input)
|
||||
|
||||
expect(output).not.toContain('```')
|
||||
expect(output).toContain("Here's your scene:")
|
||||
expect(output).not.toContain('http://localhost:8812/')
|
||||
expect(output).toContain('- **Multicolored cube**')
|
||||
})
|
||||
|
||||
it('demotes invalid fenced prose blocks with closers', () => {
|
||||
const fence = '```'
|
||||
const input = [
|
||||
`${fence} http://localhost:8812/`,
|
||||
'- **Scroll wheel** - zoom',
|
||||
'- **Right-drag/pan** - disabled',
|
||||
fence
|
||||
].join('\n')
|
||||
|
||||
const output = preprocessMarkdown(input)
|
||||
|
||||
expect(output).not.toContain('```')
|
||||
expect(output).not.toContain('http://localhost:8812/')
|
||||
expect(output).toContain('- **Scroll wheel** - zoom')
|
||||
})
|
||||
|
||||
it('demotes prose sentence masquerading as fence info', () => {
|
||||
const input = ['```Heads up - a bunny got added', '- Pure white (`#ffffff`)', '- Ambient dropped to 0.18'].join('\n')
|
||||
const output = preprocessMarkdown(input)
|
||||
|
||||
expect(output).not.toContain('```heads')
|
||||
expect(output).toContain('Heads up - a bunny got added')
|
||||
expect(output).toContain('- Pure white (`#ffffff`)')
|
||||
})
|
||||
|
||||
it('keeps valid code fences intact', () => {
|
||||
const fence = '```'
|
||||
const input = [`${fence}ts`, 'const value = 1;', fence].join('\n')
|
||||
|
||||
const output = preprocessMarkdown(input)
|
||||
|
||||
expect(output).toContain('```ts')
|
||||
expect(output).toContain('const value = 1;')
|
||||
})
|
||||
|
||||
it('keeps dangling real code fences during streaming', () => {
|
||||
const input = ['```ts', 'const value = 1;'].join('\n')
|
||||
const output = preprocessMarkdown(input)
|
||||
|
||||
expect(output.startsWith('```ts')).toBe(true)
|
||||
expect(output).toContain('const value = 1;')
|
||||
})
|
||||
|
||||
it('demotes dangling prose fences', () => {
|
||||
const input = ['```', '- Pure white (`#ffffff`)', '- Ambient dropped to 0.18'].join('\n')
|
||||
const output = preprocessMarkdown(input)
|
||||
|
||||
expect(output).not.toContain('```')
|
||||
expect(output).toContain('- Pure white (`#ffffff`)')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user