FrontendAtlas
Study
▾
Dashboard
Pricing
Get full access
</> Code
Test cases
Language
JavaScript
TypeScript
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;'); }); });
▶ Run tests
Results
Console
Run tests to see results.