X-Git-Url: http://git.asbjorn.it/?p=jquery.git;a=blobdiff_plain;f=test%2Funit%2Fajax.js;h=b44f0773f2f40303ff7545a9a78ebe2c9fe9c65c;hp=1ed15b50c84bc04cf7b893827f0b63623903928c;hb=dc2e7317a90464e729fd9f29afaa16fa9c01487c;hpb=2e2d5e9db5ee9886644d75954d327e6d284e2da8 diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 1ed15b5..b44f077 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -2006,6 +2006,49 @@ test( "jQuery.ajax - statusCode" , function() { }); }); +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 ); + +}); + test("jQuery.ajax - active counter", function() { ok( jQuery.active == 0, "ajax active counter should be zero: " + jQuery.active ); });