X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=test%2Funit%2Fajax.js;h=2b3cfb656a47b5cb25e6b8beb1ea0814bc09c162;hb=701b072e1a104bce03df700c5f620d4000ccd573;hp=1e1e8123a9dfe429ed3e7cbf2562ac15e068a92b;hpb=62d84e44ac3b4a3673c320514bbf5ac8dc7712d6;p=jquery.git diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 1e1e812..2b3cfb6 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 ); @@ -218,23 +218,21 @@ test("synchronous request with callbacks", function() { }); test("pass-through request object", function() { - expect(1); + expect(6); stop(true); var target = "data/name.html"; var count = 0; var success = function() { - // Disabled - //if(count++ == 5) + // Re-enabled because a bug was found in the unit test that probably caused the problem + if(++count == 5) start(); }; - /* Test disabled, too many simultaneous requests ok( $.get(url(target), success), "get" ); ok( $.post(url(target), success), "post" ); ok( $.getScript(url("data/test.js"), success), "script" ); ok( $.getJSON(url("data/json_obj.js"), success), "json" ); - */ ok( $.ajax({url: url(target), success: success}), "generic" ); }); @@ -346,8 +344,6 @@ test("$.getScript(String, Function) - no callback", function() { $.getScript(url("data/test.js"), start); }); -if ( !isLocal ) { - test("$.ajax() - JSONP, Local", function() { expect(7); @@ -515,6 +511,19 @@ test("$.getJSON(String, Function) - JSON object", function() { }); }); +test("$.getJSON(String, Function) - Remote JSON object with assignment", function() { + expect(2); + + var base = window.location.href.replace(/\?.*$/, ""); + + stop(); + $.getJSON(base + "data/json_assigned_obj.js", function() { + ok( typeof json_assigned_obj == "object", 'Check JSON loaded' ); + equals( json_assigned_obj.test, "worked", 'Check JSON obj.test' ); + start(); + }); +}); + test("$.post(String, Hash, Function) - simple with xml", function() { expect(4); stop();