From 575a77c92152f0500a1ac38ad952572b1d4229f1 Mon Sep 17 00:00:00 2001 From: Steven Salat Date: Thu, 15 May 2014 14:23:05 -0700 Subject: [PATCH] Added test for parseJSON --- jquery/jquery-tests.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 973818f5a..81ddb3ae1 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -3116,6 +3116,22 @@ function test_parseHTML() { .appendTo( $log ); } +// http://api.jquery.com/jQuery.parseJSON/ +function test_parseJSON() { + // Return type should be any, not Object + var i = $.parseJSON('1'); + var a = $.parseJSON('[1]'); + var o = $.parseJSON('{"foo":"bar"}'); + var s = $.parseJSON('"string"'); + var n = $.parseJSON('null'); + + i instanceof Object; // false + a instanceof Object; // true + o instanceof Object; // true + s instanceof Object; // false + n instanceof Object; // false +} + function test_not() { $("li").not(":even").css("background-color", "red");