mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 17:07:49 +00:00
wip: code formatting nits continued
This commit is contained in:
39
test/unescape.spec.js
Normal file
39
test/unescape.spec.js
Normal file
@@ -0,0 +1,39 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user