mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
31 lines
842 B
JavaScript
31 lines
842 B
JavaScript
import assert from 'assert';
|
|
import lodashStable from 'lodash';
|
|
import escape from '../escape.js';
|
|
import unescape from '../unescape.js';
|
|
|
|
describe('escape', function() {
|
|
var escaped = '&<>"'/',
|
|
unescaped = '&<>"\'/';
|
|
|
|
escaped += escaped;
|
|
unescaped += unescaped;
|
|
|
|
it('should escape values', function() {
|
|
assert.strictEqual(escape(unescaped), escaped);
|
|
});
|
|
|
|
it('should handle strings with nothing to escape', function() {
|
|
assert.strictEqual(escape('abc'), 'abc');
|
|
});
|
|
|
|
it('should escape the same characters unescaped by `_.unescape`', function() {
|
|
assert.strictEqual(escape(unescape(escaped)), escaped);
|
|
});
|
|
|
|
lodashStable.each(['`', '/'], function(chr) {
|
|
it('should not escape the "' + chr + '" character', function() {
|
|
assert.strictEqual(escape(chr), chr);
|
|
});
|
|
});
|
|
});
|