X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=test%2Funit%2Fajax.js;h=b44f0773f2f40303ff7545a9a78ebe2c9fe9c65c;hb=dc2e7317a90464e729fd9f29afaa16fa9c01487c;hp=d262988eb85afa3f0223ea0200e1982a5af5b062;hpb=64e1cdbb95b8bbefbc9dec70ae30e0714a549619;p=jquery.git diff --git a/test/unit/ajax.js b/test/unit/ajax.js index d262988..b44f077 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -1911,9 +1911,9 @@ test( "jQuery.ajax - Location object as url (#7531)", 1, function () { test( "jQuery.ajax - statusCode" , function() { - var count = 10; + var count = 12; - expect( 16 ); + expect( 20 ); stop(); function countComplete() { @@ -1975,7 +1975,77 @@ test( "jQuery.ajax - statusCode" , function() { } }).statusCode( createStatusCodes( "all (immediately with method)" , isSuccess ) ); + var testString = ""; + + jQuery.ajax( url( uri ), { + success: function( a , b , jXHR ) { + ok( isSuccess , "success" ); + var statusCode = {}; + statusCode[ jXHR.status ] = function() { + testString += "B"; + }; + jXHR.statusCode( statusCode ); + testString += "A"; + }, + error: function( jXHR ) { + ok( ! isSuccess , "error" ); + var statusCode = {}; + statusCode[ jXHR.status ] = function() { + testString += "B"; + }; + jXHR.statusCode( statusCode ); + testString += "A"; + }, + complete: function() { + strictEqual( testString , "AB" , "Test statusCode callbacks are ordered like " + + ( isSuccess ? "success" : "error" ) + " callbacks" ); + countComplete(); + } + } ); + }); +}); + +test("jQuery.ajax - transitive conversions", function() { + + expect( 8 ); + + stop(); + + jQuery.when( + + jQuery.ajax( url("data/json.php") , { + converters: { + "json myjson": function( data ) { + ok( true , "converter called" ); + return data; + } + }, + dataType: "myjson", + success: function() { + ok( true , "Transitive conversion worked" ); + strictEqual( this.dataTypes[0] , "text" , "response was retrieved as text" ); + strictEqual( this.dataTypes[1] , "myjson" , "request expected myjson dataType" ); + } + }), + + jQuery.ajax( url("data/json.php") , { + converters: { + "json myjson": function( data ) { + ok( true , "converter called (*)" ); + return data; + } + }, + contents: false, /* headers are wrong so we ignore them */ + dataType: "* myjson", + success: function() { + ok( true , "Transitive conversion worked (*)" ); + strictEqual( this.dataTypes[0] , "text" , "response was retrieved as text (*)" ); + strictEqual( this.dataTypes[1] , "myjson" , "request expected myjson dataType (*)" ); + } + }) + + ).then( start , start ); });