mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 23:57:49 +00:00
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
import lodashStable from 'lodash';
|
|
import unescape from '../src/unescape';
|
|
import escape from '../src/escape';
|
|
|
|
describe('unescape', () => {
|
|
let escaped = '&<>"'/';
|
|
let unescaped = '&<>"\'/';
|
|
|
|
escaped += escaped;
|
|
unescaped += unescaped;
|
|
|
|
it('should unescape entities in order', () => {
|
|
expect(unescape('&lt;')).toBe('<');
|
|
});
|
|
|
|
it('should unescape the proper entities', () => {
|
|
expect(unescape(escaped)).toBe(unescaped);
|
|
});
|
|
|
|
it('should handle strings with nothing to unescape', () => {
|
|
expect(unescape('abc')).toBe('abc');
|
|
});
|
|
|
|
it('should unescape the same characters escaped by `_.escape`', () => {
|
|
expect(unescape(escape(unescaped))).toBe(unescaped);
|
|
});
|
|
|
|
it('should handle leading zeros in html entities', () => {
|
|
expect(unescape(''')).toBe("'");
|
|
expect(unescape(''')).toBe("'");
|
|
expect(unescape(''')).toBe("'");
|
|
});
|
|
|
|
lodashStable.each(['`', '/'], (entity) => {
|
|
it(`should not unescape the "${entity}" entity`, () => {
|
|
expect(unescape(entity)).toBe(entity);
|
|
});
|
|
});
|
|
});
|