import { parseSimpleMarkdown } from '../../utils/parse_simple_markdown' describe('parseSimpleMarkdown', () => { it('parses bold text correctly', () => { const input = 'This is **bold** text' const result = parseSimpleMarkdown(input) expect(result).toEqual([ { type: 'text', content: 'This is ' }, { type: 'bold', content: 'bold' }, { type: 'text', content: ' text' }, ]) }) it('parses italic text correctly', () => { const input = 'This is *italic* text' const result = parseSimpleMarkdown(input) expect(result).toEqual([ { type: 'text', content: 'This is ' }, { type: 'italic', content: 'italic' }, { type: 'text', content: ' text' }, ]) }) it('parses links correctly', () => { const input = 'Visit https://example.com/page?query=info&number=1#hash. for more info' const result = parseSimpleMarkdown(input) expect(result).toEqual([ { type: 'text', content: 'Visit ' }, { type: 'link', content: 'https://example.com/page?query=info&number=1#hash' }, { type: 'text', content: '.' }, { type: 'text', content: ' for more info' }, ]) }) it('parses mixed formatting correctly', () => { const input = 'This is **bold** and *italic* and a link: https://example.com' const result = parseSimpleMarkdown(input) expect(result).toEqual([ { type: 'text', content: 'This is ' }, { type: 'bold', content: 'bold' }, { type: 'text', content: ' and ' }, { type: 'italic', content: 'italic' }, { type: 'text', content: ' and a link: ' }, { type: 'link', content: 'https://example.com' }, ]) }) it('parses unordered lists correctly', () => { const input = '* Item 1\n* Item 2\n* Item 3' const result = parseSimpleMarkdown(input) expect(result).toEqual([{ type: 'text', content: '* Item 1\n* Item 2\n* Item 3' }]) }) it('parses ordered lists correctly', () => { const input = '1. Item 1\n2. Item 2\n3. Item 3' const result = parseSimpleMarkdown(input) expect(result).toEqual([{ type: 'text', content: '1. Item 1\n2. Item 2\n3. Item 3' }]) }) it('handles plain text without formatting', () => { const input = 'Just plain text' const result = parseSimpleMarkdown(input) expect(result).toEqual([{ type: 'text', content: 'Just plain text' }]) }) it('handles empty input', () => { const input = '' const result = parseSimpleMarkdown(input) expect(result).toEqual([]) }) it('handles multiple consecutive formatting', () => { const input = '**bold** *italic* https://example.com' const result = parseSimpleMarkdown(input) expect(result).toEqual([ { type: 'bold', content: 'bold' }, { type: 'text', content: ' ' }, { type: 'italic', content: 'italic' }, { type: 'text', content: ' ' }, { type: 'link', content: 'https://example.com' }, ]) }) it('handles unmatched formatting gracefully', () => { const input = 'This is **bold and *italic' const result = parseSimpleMarkdown(input) expect(result).toEqual([ { type: 'text', content: 'This is ' }, { type: 'italic', content: '*bold and ' }, { type: 'text', content: 'italic' }, ]) }) })