import { sanitizeHtml } from './sanitizeHtml.util'; describe('sanitizeHtml', () => { it('passes through plain text unchanged', () => { expect(sanitizeHtml('hello world')).toBe('hello world'); }); it('allows
tag', () => { expect(sanitizeHtml('line1
line2')).toBe('line1
line2'); }); it('allows tag', () => { expect(sanitizeHtml('bold')).toBe('bold'); }); it('allows tag', () => { expect(sanitizeHtml('')).toBe(''); }); it('allows
tag', () => { expect(sanitizeHtml('
x
')).toBe('
x
'); }); it('allows tag with color attribute', () => { expect(sanitizeHtml('text')).toBe('text'); }); it('strips disallowed tag ')).toBe(''); }); it('strips disallowed tag
', () => { expect(sanitizeHtml('
content
')).toBe('content'); }); it('strips disallowed attribute onclick from ', () => { expect(sanitizeHtml('hi')).toBe('hi'); }); it('adds target=_blank and rel=noopener noreferrer to tags', () => { const result = sanitizeHtml('link'); expect(result).toContain('target="_blank"'); expect(result).toContain('rel="noopener noreferrer"'); }); it('allows href attribute on ', () => { const result = sanitizeHtml('link'); expect(result).toContain('href="https://example.com"'); }); it('strips disallowed schemes like javascript:', () => { const result = sanitizeHtml('xss'); expect(result).not.toContain('javascript:'); }); });