X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fajax.js;h=5274b6850205cabb0f854dbc38c41bd5e270d75f;hb=76e3a901530609d3c4a695ccb8a48251445c6861;hp=3e2ac9f2b7ae28c82904bb41a3c6c20c95ce8698;hpb=4b8f6cdc86c395fb92c7d50e8642118963232af4;p=jquery.git diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 3e2ac9f..5274b68 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -218,26 +218,54 @@ test("synchronous request with callbacks", function() { }); test("pass-through request object", function() { - expect(1); + expect(6); stop(true); var target = "data/name.html"; var count = 0; var success = function() { - // Disabled - //if(count++ == 5) - start(); + // Re-enabled because a bug was found in the unit test that probably caused the problem + if(++count == 5) + start(); }; - /* Test disabled, too many simultaneous requests ok( $.get(url(target), success), "get" ); ok( $.post(url(target), success), "post" ); ok( $.getScript(url("data/test.js"), success), "script" ); ok( $.getJSON(url("data/json_obj.js"), success), "json" ); - */ ok( $.ajax({url: url(target), success: success}), "generic" ); }); +test("ajax cache", function () { + expect(18); + stop(); + + var count = 0; + + $("#firstp").bind("ajaxSuccess", function (e, xml, s) { + var re = /_=(.*?)(&|$)/g; + var oldOne = null; + for (var i = 0; i < 6; i++) { + var ret = re.exec(s.url); + if (!ret) { + break; + } + oldOne = ret[1]; + } + equals(i, 1, "Test to make sure only one 'no-cache' parameter is there"); + ok(oldOne != "tobereplaced555", "Test to be sure parameter (if it was there) was replaced"); + if(++count == 6) + start(); + }); + + ok( $.ajax({url: "data/text.php", cache:false}), "test with no parameters" ); + ok( $.ajax({url: "data/text.php?pizza=true", cache:false}), "test with 1 parameter" ); + ok( $.ajax({url: "data/text.php?_=tobereplaced555", cache:false}), "test with _= parameter" ); + ok( $.ajax({url: "data/text.php?pizza=true&_=tobereplaced555", cache:false}), "test with 1 parameter plus _= one" ); + ok( $.ajax({url: "data/text.php?_=tobereplaced555&tv=false", cache:false}), "test with 1 parameter plus _= one before it" ); + ok( $.ajax({url: "data/text.php?name=David&_=tobereplaced555&washere=true", cache:false}), "test with 2 parameters surrounding _= one" ); +}); + test("global ajaxSettings", function() { expect(3);