aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2012-10-19 17:18:33 -0400
committerDave Methvin <dave.methvin@gmail.com>2012-10-19 17:18:33 -0400
commit3144163f61ea89855818fab597a2b5f1074d10c3 (patch)
treeb1182b68899977c2b65c35c746b959d811c6c92c
parentc6cf30a56e29c7f8e009443611f86a4c0839b689 (diff)
downloadjquery-3144163f61ea89855818fab597a2b5f1074d10c3.tar.gz
jquery-3144163f61ea89855818fab597a2b5f1074d10c3.zip
Followup for #12751, only test on browsers with JSON.parse
-rw-r--r--test/unit/core.js69
1 files changed, 36 insertions, 33 deletions
diff --git a/test/unit/core.js b/test/unit/core.js
index 85d394e98..6738fbeb9 100644
--- a/test/unit/core.js
+++ b/test/unit/core.js
@@ -1351,49 +1351,52 @@ test("jQuery.camelCase()", function() {
});
});
-test( "JQuery.parseJSON() test internal parseJson (using fallback) to make sure that it throws like JSON.parse", function() {
- expect( 10 );
+// Ensure our window.JSON matches behavior of the native one, if it exists
+if ( window.JSON ) {
+ test( "JQuery.parseJSON() equivalence to JSON.parse", function() {
+ expect( 10 );
- var jsonParse = window.JSON;
- window.JSON = null;
+ var jsonParse = window.JSON;
+ window.JSON = null;
- raises(function() {
- jsonParse.parse("''");
- });
+ raises(function() {
+ jsonParse.parse("''");
+ });
- raises(function() {
- jQuery.parseJSON("''");
- });
+ raises(function() {
+ jQuery.parseJSON("''");
+ });
- raises(function() {
- jsonParse.parse("");
- });
+ raises(function() {
+ jsonParse.parse("");
+ });
- raises(function() {
- jQuery.parseJSON("");
- });
+ raises(function() {
+ jQuery.parseJSON("");
+ });
- raises(function() {
- jsonParse.parse({});
- });
+ raises(function() {
+ jsonParse.parse({});
+ });
- raises(function() {
- jQuery.parseJSON({});
- });
+ raises(function() {
+ jQuery.parseJSON({});
+ });
- var parsedValue = jsonParse.parse(null);
- equal( parsedValue, null );
+ var parsedValue = jsonParse.parse(null);
+ equal( parsedValue, null, "parsed null" );
- parsedValue = jQuery.parseJSON(null);
- equal( parsedValue, null );
+ parsedValue = jQuery.parseJSON(null);
+ equal( parsedValue, null, "parsed null" );
- parsedValue = jsonParse.parse("{}");
- equal( (typeof parsedValue === "object"), true );
+ parsedValue = jsonParse.parse("{}");
+ equal( (typeof parsedValue === "object"), true );
- parsedValue = jQuery.parseJSON("{}");
- equal( (typeof parsedValue === "object"), true );
-
+ parsedValue = jQuery.parseJSON("{}");
+ equal( (typeof parsedValue === "object"), true );
+
- window.JSON = jsonParse;
-} );
+ window.JSON = jsonParse;
+ });
+}