X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fajax.js;h=942f9bee7fe942114e3ff1ae4040640984e8f6e3;hb=6504751006e6848369c9bfa5758f06b5ff40ba58;hp=a049fecef524d05cbaf480cd565aac5c2ee7ef0d;hpb=cbda6c541b9f2dd8fbaa084ecce7f421e8dc3dc4;p=jquery.git diff --git a/test/unit/ajax.js b/test/unit/ajax.js index a049fec..942f9be 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -642,8 +642,12 @@ test("jQuery.ajax() - script, Remote with POST", function() { type: "POST", dataType: "script", success: function(data, status){ - ok( foobar, "Script results returned (GET, no callback)" ); - equals( status, "success", "Script results returned (GET, no callback)" ); + ok( foobar, "Script results returned (POST, no callback)" ); + equals( status, "success", "Script results returned (POST, no callback)" ); + start(); + }, + error: function(xhr) { + ok( false, "ajax error, status code: " + xhr.status ); start(); } }); @@ -689,6 +693,25 @@ test("jQuery.getJSON(String, Function) - JSON object", function() { }); }); +test("jQuery.getJSON - Using Native JSON", function() { + expect(2); + + var old = window.JSON; + JSON = { + parse: function(str){ + ok( true, "Verifying that parse method was run" ); + return true; + } + }; + + stop(); + jQuery.getJSON(url("data/json.php"), function(json) { + window.JSON = old; + equals( json, true, "Verifying return value" ); + start(); + }); +}); + test("jQuery.getJSON(String, Function) - JSON object with absolute url to local content", function() { expect(2); @@ -851,6 +874,68 @@ test("data option: evaluate function values (#2806)", function() { }) }); +test("jQuery.ajax - If-Modified-Since support", function() { + expect( 3 ); + + stop(); + + var url = "data/if_modified_since.php?ts=" + new Date(); + + jQuery.ajax({ + url: url, + ifModified: true, + success: function(data, status) { + equals(status, "success"); + + jQuery.ajax({ + url: url, + ifModified: true, + success: function(data, status) { + if ( data === "FAIL" ) { + ok(true, "Opera is incapable of doing .setRequestHeader('If-Modified-Since')."); + ok(true, "Opera is incapable of doing .setRequestHeader('If-Modified-Since')."); + } else { + equals(status, "notmodified"); + ok(data == null, "response body should be empty") + } + start(); + } + }); + } + }); +}); + +test("jQuery.ajax - Etag support", function() { + expect( 3 ); + + stop(); + + var url = "data/etag.php?ts=" + new Date(); + + jQuery.ajax({ + url: url, + ifModified: true, + success: function(data, status) { + equals(status, "success"); + + jQuery.ajax({ + url: url, + ifModified: true, + success: function(data, status) { + if ( data === "FAIL" ) { + ok(true, "Opera is incapable of doing .setRequestHeader('If-None-Match')."); + ok(true, "Opera is incapable of doing .setRequestHeader('If-None-Match')."); + } else { + equals(status, "notmodified"); + ok(data == null, "response body should be empty") + } + start(); + } + }); + } + }); +}); + } //}