import assert from 'node:assert'; import lodashStable from 'lodash'; import unescape from '../src/unescape'; import escape from '../src/escape'; describe('unescape', () => { let escaped = '&<>"'/', unescaped = '&<>"\'/'; escaped += escaped; unescaped += unescaped; it('should unescape entities in order', () => { assert.strictEqual(unescape('&lt;'), '<'); }); it('should unescape the proper entities', () => { assert.strictEqual(unescape(escaped), unescaped); }); it('should handle strings with nothing to unescape', () => { assert.strictEqual(unescape('abc'), 'abc'); }); it('should unescape the same characters escaped by `_.escape`', () => { assert.strictEqual(unescape(escape(unescaped)), unescaped); }); it('should handle leading zeros in html entities', () => { assert.strictEqual(unescape('''), "'"); assert.strictEqual(unescape('''), "'"); assert.strictEqual(unescape('''), "'"); }); lodashStable.each(['`', '/'], (entity) => { it(`should not unescape the "${entity}" entity`, () => { assert.strictEqual(unescape(entity), entity); }); }); });