aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/ajax.js
diff options
context:
space:
mode:
authorjaubourg <j@ubourg.net>2011-01-20 04:12:15 +0100
committerjaubourg <j@ubourg.net>2011-01-20 04:12:15 +0100
commit64e1cdbb95b8bbefbc9dec70ae30e0714a549619 (patch)
tree012b38898366a0c150f2b7d32aaa7d65522daa44 /test/unit/ajax.js
parent96b00a493522fd3995f0752803da2c13bbf21755 (diff)
downloadjquery-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.js41
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();