X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fajax.js;h=162650f3bec16c66239c10b6bcfd2ada05676d62;hb=b45325765327d257f00b55cd5383287c1bd94875;hp=22caf2ac07812ad27e5f285314737452cb79fd40;hpb=6d71a10ed2b751f0e275506b24b82d5f611bfdac;p=jquery.git diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 22caf2a..162650f 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -5,6 +5,8 @@ module("ajax"); // tests and they'll pass //if ( !jQuery.browser.safari ) { +if ( !isLocal ) { + test("$.ajax() - success callbacks", function() { expect( 8 ); @@ -38,37 +40,35 @@ test("$.ajax() - success callbacks", function() { }, 13); }); -if ( !isLocal ) { - test("$.ajax() - error callbacks", function() { - expect( 8 ); - stop(); - - $('#foo').ajaxStart(function(){ - ok( true, "ajaxStart" ); - }).ajaxStop(function(){ - ok( true, "ajaxStop" ); - start(); - }).ajaxSend(function(){ - ok( true, "ajaxSend" ); - }).ajaxComplete(function(){ - ok( true, "ajaxComplete" ); - }).ajaxError(function(){ - ok( true, "ajaxError" ); - }).ajaxSuccess(function(){ - ok( false, "ajaxSuccess" ); - }); - - $.ajaxSetup({ timeout: 500 }); - - $.ajax({ - url: url("data/name.php?wait=5"), - beforeSend: function(){ ok(true, "beforeSend"); }, - success: function(){ ok(false, "success"); }, - error: function(){ ok(true, "error"); }, - complete: function(){ ok(true, "complete"); } - }); - }); -} +test("$.ajax() - error callbacks", function() { + expect( 8 ); + stop(); + + $('#foo').ajaxStart(function(){ + ok( true, "ajaxStart" ); + }).ajaxStop(function(){ + ok( true, "ajaxStop" ); + start(); + }).ajaxSend(function(){ + ok( true, "ajaxSend" ); + }).ajaxComplete(function(){ + ok( true, "ajaxComplete" ); + }).ajaxError(function(){ + ok( true, "ajaxError" ); + }).ajaxSuccess(function(){ + ok( false, "ajaxSuccess" ); + }); + + $.ajaxSetup({ timeout: 500 }); + + $.ajax({ + url: url("data/name.php?wait=5"), + beforeSend: function(){ ok(true, "beforeSend"); }, + success: function(){ ok(false, "success"); }, + error: function(){ ok(true, "error"); }, + complete: function(){ ok(true, "complete"); } + }); +}); test("$.ajax() - disabled globals", function() { expect( 3 ); @@ -346,8 +346,6 @@ test("$.getScript(String, Function) - no callback", function() { $.getScript(url("data/test.js"), start); }); -if ( !isLocal ) { - test("$.ajax() - JSONP, Local", function() { expect(7); @@ -516,13 +514,20 @@ test("$.getJSON(String, Function) - JSON object", function() { }); test("$.post(String, Hash, Function) - simple with xml", function() { - expect(2); + expect(4); stop(); $.post(url("data/name.php"), {xml: "5-2"}, function(xml){ $('math', xml).each(function() { ok( $('calculation', this).text() == '5-2', 'Check for XML' ); ok( $('result', this).text() == '3', 'Check for XML' ); }); + }); + + $.post(url("data/name.php?xml=5-2"), {}, function(xml){ + $('math', xml).each(function() { + ok( $('calculation', this).text() == '5-2', 'Check for XML' ); + ok( $('result', this).text() == '3', 'Check for XML' ); + }); start(); }); });