X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fajax.js;h=4d63ce5a6d39cd33b80808638a03f5c99617dadb;hb=65ebf57c1e5d7fa96536b66d4fcacbafad8dc1e5;hp=5d791be4fe2e2b8c67f6ef123dd9291e5c8ab1db;hpb=67089eedf6f84acd9c16ea2a6dadadf7b13a7c84;p=jquery.git diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 5d791be..4d63ce5 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -74,7 +74,7 @@ test("Ajax events with context", function() { expect(6); stop(); - var context = {}; + var context = document.createElement("div"); function event(e){ equals( this, context, e.type ); @@ -368,6 +368,10 @@ test("ajax cache", function () { ok( jQuery.ajax({url: "data/text.php?name=David&_=tobereplaced555&washere=true", cache:false}), "test with 2 parameters surrounding _= one" ); }); +/* + * Test disabled. + * The assertions expect that the passed-in object will be modified, + * which shouldn't be the case. Fixes #5439. test("global ajaxSettings", function() { expect(2); @@ -389,6 +393,7 @@ test("global ajaxSettings", function() { jQuery.ajaxSettings = tmp; }); +*/ test("load(String)", function() { expect(1); @@ -513,10 +518,10 @@ test("jQuery.getScript(String, Function) - no callback", function() { }); test("jQuery.ajax() - JSONP, Local", function() { - expect(7); + expect(8); var count = 0; - function plus(){ if ( ++count == 7 ) start(); } + function plus(){ if ( ++count == 8 ) start(); } stop(); @@ -575,6 +580,20 @@ test("jQuery.ajax() - JSONP, Local", function() { }); jQuery.ajax({ + url: "data/jsonp.php", + dataType: "jsonp", + jsonpCallback: "jsonpResults", + success: function(data){ + ok( data.data, "JSON results returned (GET, custom callback name)" ); + plus(); + }, + error: function(data){ + ok( false, "Ajax error JSON (GET, custom callback name)" ); + plus(); + } + }); + + jQuery.ajax({ type: "POST", url: "data/jsonp.php", dataType: "jsonp", @@ -619,6 +638,22 @@ test("jQuery.ajax() - JSONP, Local", function() { }); }); +test("JSONP - Custom JSONP Callback", function() { + expect(1); + stop(); + + window.jsonpResults = function(data) { + ok( data.data, "JSON results returned (GET, custom callback function)" ); + start(); + }; + + jQuery.ajax({ + url: "data/jsonp.php", + dataType: "jsonp", + jsonpCallback: "jsonpResults" + }); +}); + test("jQuery.ajax() - JSONP, Remote", function() { expect(4); @@ -780,12 +815,9 @@ test("jQuery.getJSON - Using Native JSON", function() { stop(); jQuery.getJSON(url("data/json.php"), function(json) { - if (!old) - delete window.JSON - else - window.JSON = old; - equals( json, true, "Verifying return value" ); - start(); + window.JSON = old; + equals( json, true, "Verifying return value" ); + start(); }); });