X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fajax.js;h=f7c67b7bee2af99e0ec7d95f248c8835835e82d1;hb=daffb954e397bd5d9f8e9aaedab6c0baa9609e1e;hp=4478c9b89f58c1264946db9030e906aaede80661;hpb=183f37e4b4128af7ba096ac40046768b84b6d66e;p=jquery.git diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 4478c9b..f7c67b7 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -726,9 +726,10 @@ test("jQuery.ajax() - script, Remote with scheme-less URL", function() { }); test("jQuery.getJSON(String, Hash, Function) - JSON array", function() { - expect(4); + expect(5); stop(); jQuery.getJSON(url("data/json.php"), {json: "array"}, function(json) { + ok( json.length >= 2, "Check length"); equals( json[0].name, 'John', 'Check JSON: first, name' ); equals( json[0].age, 21, 'Check JSON: first, age' ); equals( json[1].name, 'Peter', 'Check JSON: second, name' ); @@ -741,8 +742,10 @@ test("jQuery.getJSON(String, Function) - JSON object", function() { expect(2); stop(); jQuery.getJSON(url("data/json.php"), function(json) { - equals( json.data.lang, 'en', 'Check JSON: lang' ); - equals( json.data.length, 25, 'Check JSON: length' ); + if (json && json.data) { + equals( json.data.lang, 'en', 'Check JSON: lang' ); + equals( json.data.length, 25, 'Check JSON: length' ); + } start(); }); }); @@ -760,7 +763,10 @@ test("jQuery.getJSON - Using Native JSON", function() { stop(); jQuery.getJSON(url("data/json.php"), function(json) { - window.JSON = old; + if (!old) + delete window.JSON + else + window.JSON = old; equals( json, true, "Verifying return value" ); start(); });