X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fajax.js;h=7f3f39aff46c370ceed5e25c47f940fce8b83bdb;hb=ba9e0fc177841bd74cc5ea4e52f09cd87d747bf5;hp=ce257f88a84a43e2114c340a5c3cbfefe082fd2b;hpb=dcf0fa5048ef2379d551f29ffa29b14ec5ee09d5;p=jquery.git diff --git a/test/unit/ajax.js b/test/unit/ajax.js index ce257f8..7f3f39a 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -68,6 +68,18 @@ test("jQuery.ajax() - error callbacks", function() { }); }); +test(".ajax() - 304", function() { + expect( 1 ); + stop(); + + jQuery.ajax({ + url: url("data/notmodified.php"), + success: function(){ ok(true, "304 ok"); }, + error: function(){ ok(false, "304 not ok "); }, + complete: function(xhr){ start(); } + }); +}); + test(".load()) - 404 error callbacks", function() { expect( 6 ); stop(); @@ -774,7 +786,7 @@ test("jQuery.ajax() - JSONP, Remote", function() { var count = 0; function plus(){ if ( ++count == 4 ) start(); } - var base = window.location.href.replace(/\?.*$/, ""); + var base = window.location.href.replace(/[^\/]*$/, ""); stop(); @@ -836,7 +848,7 @@ test("jQuery.ajax() - JSONP, Remote", function() { test("jQuery.ajax() - script, Remote", function() { expect(2); - var base = window.location.href.replace(/\?.*$/, ""); + var base = window.location.href.replace(/[^\/]*$/, ""); stop(); @@ -853,7 +865,7 @@ test("jQuery.ajax() - script, Remote", function() { test("jQuery.ajax() - script, Remote with POST", function() { expect(3); - var base = window.location.href.replace(/\?.*$/, ""); + var base = window.location.href.replace(/[^\/]*$/, ""); stop(); @@ -876,7 +888,7 @@ test("jQuery.ajax() - script, Remote with POST", function() { test("jQuery.ajax() - script, Remote with scheme-less URL", function() { expect(2); - var base = window.location.href.replace(/\?.*$/, ""); + var base = window.location.href.replace(/[^\/]*$/, ""); base = base.replace(/^.*?\/\//, "//"); stop(); @@ -991,7 +1003,7 @@ test("jQuery.getJSON - Using Native JSON", function() { test("jQuery.getJSON(String, Function) - JSON object with absolute url to local content", function() { expect(2); - var base = window.location.href.replace(/\?.*$/, ""); + var base = window.location.href.replace(/[^\/]*$/, ""); stop(); jQuery.getJSON(url(base + "data/json.php"), function(json) { @@ -1163,6 +1175,19 @@ test("data option: evaluate function values (#2806)", function() { }) }); +test("data option: empty bodies for non-GET requests", function() { + stop(); + jQuery.ajax({ + url: "data/echoData.php", + data: undefined, + type: "post", + success: function(result) { + equals( result, "" ); + start(); + } + }) +}); + test("jQuery.ajax - If-Modified-Since support", function() { expect( 3 ); @@ -1225,6 +1250,12 @@ test("jQuery.ajax - Etag support", function() { }); }); + +test("jQuery.ajax - active counter", function() { + ok( jQuery.ajax.active == 0, "ajax active counter should be zero: " + jQuery.ajax.active ); +}); + + } //}