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