X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fcore.js;h=54ad982d24f5d44d9bf244c2776d73eec33519c9;hb=781fe8b80d08b287e4c6e4ca408f773c6a1f3b2d;hp=a61f8ba0f23348ac2a45bff44b9e2267fe3bc14a;hpb=ea9e0ed841f0f2851162e01d5199052872ba7483;p=jquery.git diff --git a/test/unit/core.js b/test/unit/core.js index a61f8ba..54ad982 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -805,3 +805,28 @@ test("jQuery.proxy", function(){ // Use the string shortcut jQuery.proxy( thisObject, "method" )(); }); + +test("jQuery.parseJSON", function(){ + expect(7); + + equals( jQuery.parseJSON(), null, "Nothing in, null out." ); + equals( jQuery.parseJSON( null ), null, "Nothing in, null out." ); + equals( jQuery.parseJSON( "" ), null, "Nothing in, null out." ); + + same( jQuery.parseJSON("{}"), {}, "Plain object parsing." ); + same( jQuery.parseJSON('{"test":1}'), {"test":1}, "Plain object parsing." ); + + try { + jQuery.parseJSON("{a:1}"); + ok( false, "Test malformed JSON string." ); + } catch( e ) { + ok( true, "Test malformed JSON string." ); + } + + try { + jQuery.parseJSON("{'a':1}"); + ok( false, "Test malformed JSON string." ); + } catch( e ) { + ok( true, "Test malformed JSON string." ); + } +}); \ No newline at end of file