mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
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);
|
|
});
|
|
|
|
it('should handle leading zeros in html entities', function() {
|
|
assert.strictEqual(unescape('''), "'");
|
|
assert.strictEqual(unescape('''), "'");
|
|
assert.strictEqual(unescape('''), "'");
|
|
});
|
|
|
|
lodashStable.each(['`', '/'], function(entity) {
|
|
it('should not unescape the "' + entity + '" entity', function() {
|
|
assert.strictEqual(unescape(entity), entity);
|
|
});
|
|
});
|
|
});
|