X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;ds=inline;f=test%2Funit%2Fajax.js;h=f6809d539e5ded464c952946099f44dd9001978e;hb=0252b78201f817f87d10f14c85d0f37e4c50ce22;hp=cd3aba0a4ba3f00e4f8350eba6bb758e5845d33a;hpb=c639405c4d1ec462b032ccfb571a6c73212ba101;p=jquery.git diff --git a/test/unit/ajax.js b/test/unit/ajax.js index cd3aba0..f6809d5 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -180,6 +180,27 @@ test("Ajax events with context", function() { }); }); +test("jQuery.ajax context modification", function() { + expect(1); + + stop(); + + var obj = {} + + jQuery.ajax({ + url: url("data/name.html"), + context: obj, + beforeSend: function(){ + this.test = "foo"; + }, + complete: function() { + start(); + } + }); + + equals( obj.test, "foo", "Make sure the original object is maintained." ); +}); + test("jQuery.ajax() - disabled globals", function() { expect( 3 ); stop(); @@ -871,7 +892,7 @@ test("jQuery.ajax() - script, Remote with scheme-less URL", function() { }); test("jQuery.ajax() - malformed JSON", function() { - expect(1); + expect(2); stop(); @@ -882,8 +903,9 @@ test("jQuery.ajax() - malformed JSON", function() { ok( false, "Success." ); start(); }, - error: function(xhr, msg) { + error: function(xhr, msg, detailedMsg) { equals( "parsererror", msg, "A parse error occurred." ); + ok( /^Invalid JSON/.test(detailedMsg), "Detailed parsererror message provided" ); start(); } }); @@ -979,6 +1001,19 @@ test("jQuery.getJSON(String, Function) - JSON object with absolute url to local }); }); +test("jQuery.post - data", function() { + expect(2); + stop(); + + jQuery.post(url("data/name.php"), {xml: "5-2", length: 3}, function(xml){ + jQuery('math', xml).each(function() { + equals( jQuery('calculation', this).text(), '5-2', 'Check for XML' ); + equals( jQuery('result', this).text(), '3', 'Check for XML' ); + }); + start(); + }); +}); + test("jQuery.post(String, Hash, Function) - simple with xml", function() { expect(4); stop();