import { describe, it, expect } from 'vitest'; import { sanitizeEmailHtml, sanitizeSignatureHtml, parseHtmlSafely, hasRichFormatting, } from '../email-sanitization'; describe('email-sanitization', () => { describe('sanitizeEmailHtml', () => { it('should remove script tags', () => { const malicious = '
Hello
'; const clean = sanitizeEmailHtml(malicious); expect(clean).not.toContain(''; const clean = sanitizeSignatureHtml(malicious); expect(clean).not.toContain(''; parseHtmlSafely(html); expect(executed).toBe(false); }); it('should handle malformed HTML gracefully', () => { const malformed = 'Unclosed
| Data |
';
expect(hasRichFormatting(html)).toBe(true);
});
it('should detect inline styles', () => {
const html = 'Just plain text
'; expect(hasRichFormatting(plain)).toBe(false); }); it('should return false for simple paragraphs', () => { const simple = 'Line 1
Line 2
'; expect(hasRichFormatting(simple)).toBe(false); }); it('should handle empty HTML', () => { expect(hasRichFormatting('')).toBe(false); expect(hasRichFormatting(' ')).toBe(false); }); }); });