mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 01:57:50 +00:00
wip: migrate to bun
This commit is contained in:
40
test/unescape.spec.ts
Normal file
40
test/unescape.spec.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user