aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorjaubourg <j@ubourg.net>2011-01-21 03:58:28 +0100
committerjaubourg <j@ubourg.net>2011-01-21 03:58:28 +0100
commitdc2e7317a90464e729fd9f29afaa16fa9c01487c (patch)
tree9bbffaa85a93e971f65ee2de54d04204cd6fc635 /test
parent2e2d5e9db5ee9886644d75954d327e6d284e2da8 (diff)
downloadjquery-dc2e7317a90464e729fd9f29afaa16fa9c01487c.tar.gz
jquery-dc2e7317a90464e729fd9f29afaa16fa9c01487c.zip
Replaces "text in-between" technique with a full-fledged one-level transitive search for converters (unit tests added). Also cleans up auto dataType determination and adds converter checks in order to guess the best dataType possible.
Diffstat (limited to 'test')
-rw-r--r--test/unit/ajax.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/unit/ajax.js b/test/unit/ajax.js
index 1ed15b50c..b44f0773f 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 );
});