Files
lodash/test/escape.test.js
2020-01-08 22:43:03 +01:00

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);
});
});
});