test(admin): unit and browser tests for the mail editor fields
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
32
admin/tests/form/insertImage.test.ts
Normal file
32
admin/tests/form/insertImage.test.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
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" <c>',
|
||||
'<img src="https://cdn.example.com/a"b.png" alt="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(
|
||||
'',
|
||||
)
|
||||
expect(insertImage('html', 'https://cdn.example.com/x.png', '')).toBe(
|
||||
'<img src="https://cdn.example.com/x.png" alt="">',
|
||||
)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user