import { describe, it, expect } from 'vitest' // Reproduce the stripHtml logic from markdown-renderer to test it in isolation function stripHtml(content: string): string { return content.replace(/<[^>]*>/g, '') } describe('stripHtml', () => { it('removes simple HTML tags', () => { expect(stripHtml('
Hello
')).toBe('Hello') }) it('removes self-closing tags', () => { expect(stripHtml('Before
embedded image'
expect(stripHtml(input)).toBe('Description with embedded image')
})
it('removes nested HTML tags', () => {
expect(stripHtml('
text
'
expect(stripHtml(input)).toBe('text')
})
it('removes HTML comments', () => {
expect(stripHtml('Before After')).toBe('Before After')
})
it('handles tags with attributes and whitespace', () => {
const input = 'Link text'
expect(stripHtml(input)).toBe('Link text')
})
it('preserves angle brackets that are not HTML tags', () => {
// This is a limitation — mathematical expressions like "x < 5" would be affected
// But for our use case (stripping pasted HTML), this is acceptable
expect(stripHtml('5 > 3 is true')).toBe('5 > 3 is true')
})
})