diff options
author | jaubourg <j@ubourg.net> | 2011-01-20 04:12:15 +0100 |
---|---|---|
committer | jaubourg <j@ubourg.net> | 2011-01-20 04:12:15 +0100 |
commit | 64e1cdbb95b8bbefbc9dec70ae30e0714a549619 (patch) | |
tree | 012b38898366a0c150f2b7d32aaa7d65522daa44 /test/unit/ajax.js | |
parent | 96b00a493522fd3995f0752803da2c13bbf21755 (diff) | |
download | jquery-64e1cdbb95b8bbefbc9dec70ae30e0714a549619.tar.gz jquery-64e1cdbb95b8bbefbc9dec70ae30e0714a549619.zip |
Cleans up and simplifies code shared by ajaxPrefilter and ajaxTransport. Removes chainability of ajaxSetup, ajaxPrefilter and ajaxTransport. Also makes sure context is handled properly by ajaxSetup (unit test added).
Diffstat (limited to 'test/unit/ajax.js')
-rw-r--r-- | test/unit/ajax.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 52b059755..d262988eb 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -599,6 +599,47 @@ test("jQuery.ajax context modification", function() { equals( obj.test, "foo", "Make sure the original object is maintained." ); }); +test("jQuery.ajax context modification through ajaxSetup", function() { + expect(4); + + stop(); + + var obj = {}; + + jQuery.ajaxSetup({ + context: obj + }); + + strictEqual( jQuery.ajaxSettings.context, obj, "Make sure the context is properly set in ajaxSettings." ); + + jQuery.ajax({ + url: url("data/name.html"), + complete: function() { + strictEqual( this, obj, "Make sure the original object is maintained." ); + jQuery.ajax({ + url: url("data/name.html"), + context: {}, + complete: function() { + ok( this !== obj, "Make sure overidding context is possible." ); + jQuery.ajaxSetup({ + context: false + }); + jQuery.ajax({ + url: url("data/name.html"), + beforeSend: function(){ + this.test = "foo2"; + }, + complete: function() { + ok( this !== obj, "Make sure unsetting context is possible." ); + start(); + } + }); + } + }); + } + }); +}); + test("jQuery.ajax() - disabled globals", function() { expect( 3 ); stop(); |