X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fajax.js;h=8dcf7591e65b6385e8d767911d48db3715230c38;hb=8a356f0d23bca2b2ea81a8320f6ab3b48b4177e3;hp=40ec9641565fb0047293d86a854dd5d912e59794;hpb=c6a44c7943f460594a6a75081ad9bce76fea80f0;p=jquery.git diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 40ec964..8dcf759 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -317,6 +317,19 @@ test("load('url selector')", function() { }); }); +test("load(String, Function) with ajaxSetup on dataType json, see #2046", function() { + expect(1); + stop(); + $.ajaxSetup({ dataType: "json" }); + $("#first").ajaxComplete(function (e, xml, s) { + equals( s.dataType, "html", "Verify the load() dataType was html" ); + $("#first").unbind("ajaxComplete"); + $.ajaxSetup({ dataType: "" }); + start(); + }); + $('#first').load("data/test3.html"); +}); + test("load(String, Function) - simple: inject text into DOM", function() { expect(2); stop(); @@ -332,15 +345,15 @@ test("load(String, Function) - check scripts", function() { window.testFoo = undefined; window.foobar = null; var verifyEvaluation = function() { - equals( foobar, "bar", 'Check if script src was evaluated after load' ); - equals( $('#ap').html(), 'bar', 'Check if script evaluation has modified DOM'); - start(); + equals( foobar, "bar", 'Check if script src was evaluated after load' ); + equals( $('#ap').html(), 'bar', 'Check if script evaluation has modified DOM'); + start(); }; $('#first').load(url('data/test.html'), function() { - ok( $('#first').html().match(/^html text/), 'Check content after loading html' ); - equals( $('#foo').html(), 'foo', 'Check if script evaluation has modified DOM'); - equals( testFoo, "foo", 'Check if script was evaluated after load' ); - setTimeout(verifyEvaluation, 600); + ok( $('#first').html().match(/^html text/), 'Check content after loading html' ); + equals( $('#foo').html(), 'foo', 'Check if script evaluation has modified DOM'); + equals( testFoo, "foo", 'Check if script was evaluated after load' ); + setTimeout(verifyEvaluation, 600); }); }); @@ -349,9 +362,9 @@ test("load(String, Function) - check file with only a script tag", function() { stop(); testFoo = undefined; $('#first').load(url('data/test2.html'), function() { - ok( $('#foo').html() == 'foo', 'Check if script evaluation has modified DOM'); - ok( testFoo == "foo", 'Check if script was evaluated after load' ); - start(); + ok( $('#foo').html() == 'foo', 'Check if script evaluation has modified DOM'); + ok( testFoo == "foo", 'Check if script was evaluated after load' ); + start(); }); }); @@ -372,6 +385,7 @@ test("$.get(String, Hash, Function) - parse xml and use text() on nodes", functi test("$.getScript(String, Function) - with callback", function() { expect(2); stop(); + window.foobar = null; $.getScript(url("data/test.js"), function() { equals( foobar, "bar", 'Check if script was evaluated' ); setTimeout(start, 100); @@ -435,7 +449,7 @@ test("$.ajax() - JSONP, Local", function() { $.ajax({ url: "data/jsonp.php", dataType: "jsonp", - data: { callback: "?" }, + jsonp: "callback", success: function(data){ ok( data.data, "JSON results returned (GET, data obj callback)" ); plus(); @@ -478,7 +492,7 @@ test("$.ajax() - JSONP, Local", function() { $.ajax({ type: "POST", url: "data/jsonp.php", - data: { callback: "?" }, + jsonp: "callback", dataType: "jsonp", success: function(data){ ok( data.data, "JSON results returned (POST, data obj callback)" ); @@ -544,7 +558,7 @@ test("$.ajax() - JSONP, Remote", function() { $.ajax({ url: base + "data/jsonp.php", dataType: "jsonp", - data: { callback: "?" }, + jsonp: "callback", success: function(data){ ok( data.data, "JSON results returned (GET, data obj callback)" ); plus(); @@ -563,6 +577,7 @@ test("$.ajax() - script, Remote", function() { stop(); + window.foobar = null; $.ajax({ url: base + "data/test.js", dataType: "script", @@ -580,6 +595,7 @@ test("$.ajax() - script, Remote with POST", function() { stop(); + window.foobar = null; $.ajax({ url: base + "data/test.js", type: "POST", @@ -592,6 +608,25 @@ test("$.ajax() - script, Remote with POST", function() { }); }); +test("$.ajax() - script, Remote with scheme-less URL", function() { + expect(2); + + var base = window.location.href.replace(/\?.*$/, ""); + base = base.replace(/^.*?\/\//, "//"); + + stop(); + + window.foobar = null; + $.ajax({ + url: base + "data/test.js", + dataType: "script", + success: function(data){ + ok( foobar, "Script results returned (GET, no callback)" ); + start(); + } + }); +}); + test("$.getJSON(String, Hash, Function) - JSON array", function() { expect(4); stop();