export default function escapeHtml(text) {
throw new Error('Not implemented');
}
Run tests to see results.
export default function escapeHtml(text) {
throw new Error('Not implemented');
}
import escapeHtml from './escapeHtml';
describe('escapeHtml', () => {
test('escapes HTML special characters', () => {
const input = '<div class="x">Tom & Jerry\'s</div>';
const out = '<div class="x">Tom & Jerry's</div>';
expect(escapeHtml(input)).toBe(out);
});
test('leaves safe text unchanged', () => {
expect(escapeHtml('hello world')).toBe('hello world');
});
test('escapes ampersands in existing entities', () => {
expect(escapeHtml('<script>')).toBe('&lt;script&gt;');
});
});