X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fajax.js;h=74c6545c5cb9ce6f7d4fb3e5b44a8f192c55d432;hb=43a41ba7ecef732b48dcfc930fa9df8835fc4944;hp=c2d572906dd8d53a5d7e70aca62ef3d2f4051779;hpb=08fcde6a59e5bb6ca9e58bf78aac64ff2c15c29d;p=jquery.git diff --git a/test/unit/ajax.js b/test/unit/ajax.js index c2d5729..74c6545 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -348,10 +348,14 @@ test(".ajax() - headers" , function() { stop(); + jQuery('#foo').ajaxSend(function( evt, xhr ) { + xhr.setRequestHeader( "ajax-send", "test" ); + }); + var requestHeaders = { - siMPle: "value", - "SometHing-elsE": "other value", - OthEr: "something else" + siMPle: "value", + "SometHing-elsE": "other value", + OthEr: "something else" }, list = [], i; @@ -359,22 +363,25 @@ test(".ajax() - headers" , function() { for( i in requestHeaders ) { list.push( i ); } + list.push( "ajax-send" ); jQuery.ajax(url("data/headers.php?keys="+list.join( "_" ) ), { + headers: requestHeaders, success: function( data , _ , xhr ) { var tmp = []; for ( i in requestHeaders ) { tmp.push( i , ": " , requestHeaders[ i ] , "\n" ); } + tmp.push( "ajax-send: test\n" ); tmp = tmp.join( "" ); equals( data , tmp , "Headers were sent" ); equals( xhr.getResponseHeader( "Sample-Header" ) , "Hello World" , "Sample header received" ); - start(); }, error: function(){ ok(false, "error"); } - }); + + }).then( start, start ); }); @@ -524,7 +531,7 @@ test("jQuery ajax - cross-domain detection", function() { }); -test(".load()) - 404 error callbacks", function() { +test(".load() - 404 error callbacks", function() { expect( 6 ); stop(); @@ -2162,6 +2169,34 @@ test("jQuery.ajax - transitive conversions", function() { }); +test("jQuery.ajax - overrideMimeType", function() { + + expect( 2 ); + + stop(); + + jQuery.when( + + jQuery.ajax( url("data/json.php") , { + beforeSend: function( xhr ) { + xhr.overrideMimeType( "application/json" ); + }, + success: function( json ) { + ok( json.data , "Mimetype overriden using beforeSend" ); + } + }), + + jQuery.ajax( url("data/json.php") , { + mimeType: "application/json", + success: function( json ) { + ok( json.data , "Mimetype overriden using mimeType option" ); + } + }) + + ).then( start , start ); + +}); + test("jQuery.ajax - abort in prefilter", function() { expect( 1 );