import { describe, expect, it } from 'vitest' import { insertImage } from '../../src/components/mail/insertImage' describe('insertImage (UI-SPEC C4)', () => { it.each([ [ 'markdown', 'https://cdn.example.com/a b(c).png', 'Logo [x]', '![Logo \\[x\\]](https://cdn.example.com/a%20b%28c%29.png)', ], [ 'html', 'https://cdn.example.com/a"b.png', 'a "b" ', 'a "b" <c>', ], ['css', 'https://cdn.example.com/a.png', 'ignored', 'url("https://cdn.example.com/a.png")'], ['text', 'https://cdn.example.com/a.png', 'ignored', 'https://cdn.example.com/a.png'], ] as const)('builds %s snippets with escaping', (language, url, alt, want) => { expect(insertImage(language, url, alt)).toBe(want) }) it('handles empty alt and parentheses in markdown URLs', () => { expect(insertImage('markdown', 'https://cdn.example.com/x(y).png', '')).toBe( '![](https://cdn.example.com/x%28y%29.png)', ) expect(insertImage('html', 'https://cdn.example.com/x.png', '')).toBe( '', ) }) })