forked from PinSpace-Org/GistPin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsanitize.spec.ts
More file actions
32 lines (25 loc) · 955 Bytes
/
Copy pathsanitize.spec.ts
File metadata and controls
32 lines (25 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { stripHtml } from './sanitize';
describe('stripHtml', () => {
it('should strip HTML tags', () => {
expect(stripHtml('<script>alert("xss")</script>Hello')).toBe('Hello');
});
it('should strip inline tags', () => {
expect(stripHtml('<b>bold</b> text')).toBe('bold text');
});
it('should decode HTML entities', () => {
expect(stripHtml('<div>test</div>')).toBe('<div>test</div>');
});
it('should preserve plain text', () => {
expect(stripHtml('Hello from Abuja!')).toBe('Hello from Abuja!');
});
it('should preserve emojis and unicode', () => {
expect(stripHtml('Hello 🌍 from Abuja!')).toBe('Hello 🌍 from Abuja!');
expect(stripHtml('Ẽmoji tëst 日本語')).toBe('Ẽmoji tëst 日本語');
});
it('should trim whitespace', () => {
expect(stripHtml(' hello ')).toBe('hello');
});
it('should handle empty string', () => {
expect(stripHtml('')).toBe('');
});
});