Add _.unescape method. [closes #63]

Former-commit-id: 10eada385fd0e1157271a2da6fb32de047d6d88a
This commit is contained in:
John-David Dalton
2012-08-27 02:05:37 -07:00
parent ce440e9f43
commit 8c911a2fd0
3 changed files with 90 additions and 18 deletions

View File

@@ -395,15 +395,11 @@
QUnit.module('lodash.escape');
(function() {
test('should not escape the ">" character', function() {
equal(_.escape('>'), '>');
});
test('should not escape the "/" character', function() {
equal(_.escape('/'), '/');
});
test('should return empty string when passed `null` or `undefined`', function() {
test('should return an empty string when passed `null` or `undefined`', function() {
equal(_.escape(null), '');
equal(_.escape(undefined), '');
});
@@ -1540,6 +1536,30 @@
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.unescape');
(function() {
test('should perform a case-insensitive replacement of numeric character references', function() {
equal(_.unescape(''x''), "'x'");
});
test('should unescape entities in the correct order', function() {
equal(_.unescape('<'), '<');
});
test('should unescape the proper entities', function() {
var escaped = '<h1>Moe's famous "death by chocolate" brownies & cake<\/h1>';
equal(_.unescape(escaped), '<h1>Moe\'s famous "death by chocolate" brownies & cake<\/h1>');
});
test('should return an empty string when passed `null` or `undefined`', function() {
equal(_.unescape(null), '');
equal(_.unescape(undefined), '');
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.uniq');
(function() {