aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/ajax.js
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2016-04-26 10:28:02 -0400
committerDave Methvin <dave.methvin@gmail.com>2016-04-27 09:06:43 -0400
commitdf2051cf59d054d7ee91bdb554b583471942c6b4 (patch)
tree396a3292fa99fb28bb159b0f95103f6d141540af /test/unit/ajax.js
parent4f270427d24ca9b7591189c802e595ede6a92654 (diff)
downloadjquery-df2051cf59d054d7ee91bdb554b583471942c6b4.tar.gz
jquery-df2051cf59d054d7ee91bdb554b583471942c6b4.zip
Ajax: Ensure ajaxSettings.traditional is still honored
Fixes gh-3023 Closes gh-3081 Since .param() no longer looks at this setting we need unit tests to ensure it is still honored by $.ajax().
Diffstat (limited to 'test/unit/ajax.js')
-rw-r--r--test/unit/ajax.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/test/unit/ajax.js b/test/unit/ajax.js
index 1082ce88e..1a4ff7ee4 100644
--- a/test/unit/ajax.js
+++ b/test/unit/ajax.js
@@ -373,6 +373,64 @@ QUnit.module( "ajax", {
];
} );
+ ajaxTest( "jQuery.ajax() - traditional param encoding", 4, function( assert ) {
+ return [
+ {
+ url: "/",
+ traditional: true,
+ data: {
+ "devo": "hat",
+ "answer": 42,
+ "quux": "a space"
+ },
+ beforeSend: function( xhr, settings ) {
+ assert.equal( settings.url, "/?devo=hat&answer=42&quux=a%20space", "Simple case" );
+ return false;
+ },
+ error: true
+ },
+ {
+ url: "/",
+ traditional: true,
+ data: {
+ "a": [ 1, 2, 3 ],
+ "b[]": [ "b1", "b2" ]
+ },
+ beforeSend: function( xhr, settings ) {
+ assert.equal( settings.url, "/?a=1&a=2&a=3&b%5B%5D=b1&b%5B%5D=b2", "Arrays" );
+ return false;
+ },
+ error: true
+ },
+ {
+ url: "/",
+ traditional: true,
+ data: {
+ "a": [ [ 1, 2 ], [ 3, 4 ], 5 ]
+ },
+ beforeSend: function( xhr, settings ) {
+ assert.equal( settings.url, "/?a=1%2C2&a=3%2C4&a=5", "Nested arrays" );
+ return false;
+ },
+ error: true
+ },
+ {
+ url: "/",
+ traditional: true,
+ data: {
+ "a": [ "w", [ [ "x", "y" ], "z" ] ]
+ },
+ cache: false,
+ beforeSend: function( xhr, settings ) {
+ var url = settings.url.replace( /\d{3,}/, "" );
+ assert.equal( url, "/?a=w&a=x%2Cy%2Cz&_=", "Cache-buster" );
+ return false;
+ },
+ error: true
+ }
+ ];
+ } );
+
ajaxTest( "jQuery.ajax() - cross-domain detection", 8, function( assert ) {
function request( url, title, crossDomainOrOptions ) {
return jQuery.extend( {