aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/ajax.js
diff options
context:
space:
mode:
authorjaubourg <j@ubourg.net>2012-05-02 02:22:56 +0200
committerjaubourg <j@ubourg.net>2012-05-02 02:22:56 +0200
commitd3e034f6c7b086ae772bf22d37f849a2d0ab5194 (patch)
treeb75a4e5315e5ad21d96020fbedd3b08838a12185 /test/unit/ajax.js
parentae6b14abaffd5f9f3560f5448fe0fcc20db26bb5 (diff)
downloadjquery-d3e034f6c7b086ae772bf22d37f849a2d0ab5194.tar.gz
jquery-d3e034f6c7b086ae772bf22d37f849a2d0ab5194.zip
Adds unit test to show order of parameters in the load callback are off for errors since the rewrite (this test works in master).
Diffstat (limited to 'test/unit/ajax.js')
-rw-r--r--test/unit/ajax.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/unit/ajax.js b/test/unit/ajax.js
index 9960e4c70..8be1947fb 100644
--- a/test/unit/ajax.js
+++ b/test/unit/ajax.js
@@ -1275,6 +1275,48 @@ asyncTest("load() - data specified in ajaxSettings is merged in (#10524)", 1, fu
});
});
+asyncTest("load() - callbacks get the correct parameters", 8, function() {
+ var slice = [].slice,
+ completeArgs = {};
+
+ jQuery.ajaxSetup({
+ success: function( _, status, jqXHR ) {
+ completeArgs[ this.url ] = [ jqXHR.responseText, status, jqXHR ];
+ },
+ error: function( jqXHR, status ) {
+ completeArgs[ this.url ] = [ jqXHR.responseText, status, jqXHR ];
+ }
+ });
+
+ jQuery.when.apply( jQuery, jQuery.map([
+ {
+ type: "success",
+ url: "data/echoQuery.php?arg=pop"
+ },
+ {
+ type: "error",
+ url: "data/404.php"
+ }
+ ], function( options ) {
+ return jQuery.Deferred(function( defer ) {
+ jQuery("#foo").load( options.url, function() {
+ var args = arguments;
+ strictEqual( completeArgs[ options.url ].length, args.length, "same number of arguments (" + options.type + ")" );
+ jQuery.each( completeArgs[ options.url ], function( i, value ) {
+ strictEqual( args[ i ], value, "argument #" + i + " is the same (" + options.type + ")" );
+ });
+ defer.resolve();
+ });
+ });
+ }) ).always(function() {
+ jQuery.ajaxSetup({
+ success: null,
+ error: null
+ });
+ start();
+ });
+});
+
test("jQuery.get(String, Function) - data in ajaxSettings (#8277)", function() {
expect(1);
stop();