import { describe, expect, it } from 'vitest' import { completeStreamingTable, repairStreamingMarkdown } from './streamingMarkdown' describe('completeStreamingTable', () => { it('adds a delimiter row once a table header row finishes', () => { expect(completeStreamingTable('Intro\n\n| Ticker | Sentiment |')) .toBe('Intro\n\n| Ticker | Sentiment |\n| --- | --- |') }) it('completes a partially streamed delimiter row', () => { expect(completeStreamingTable('| A | B | C |\n|------|---')) .toBe('| A | B | C |\n| --- | --- | --- |') }) it('leaves complete tables and streaming body rows alone', () => { const table = '| A | B |\n|---|---|\n| 1 | 2' expect(completeStreamingTable(table)).toBe(table) }) it('ignores pipes inside an open code fence', () => { const fenced = '```\n| A | B |' expect(completeStreamingTable(fenced)).toBe(fenced) }) }) describe('repairStreamingMarkdown', () => { it('closes unterminated emphasis', () => { expect(repairStreamingMarkdown('Some **bold')).toBe('Some **bold**') }) it('shows incomplete links as text instead of a placeholder URL', () => { expect(repairStreamingMarkdown('see [the docs](https://exa')).not.toContain('streamdown:') }) })