X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fajax%2FajaxTest.js;h=f158bae2120993a450108bed487a5a84a36a6627;hb=f96bf1041553775a94c1034c97e253e350217173;hp=67bf6dd3920266181d004db0803b8365cc541f2c;hpb=d5bb0e317988965306b1ccb395fafc4554aba49c;p=jquery.git diff --git a/src/ajax/ajaxTest.js b/src/ajax/ajaxTest.js index 67bf6dd..f158bae 100644 --- a/src/ajax/ajaxTest.js +++ b/src/ajax/ajaxTest.js @@ -3,7 +3,7 @@ module("ajax"); // Safari 3 randomly crashes when running these tests, // but only in the full suite - you can run just the Ajax // tests and they'll pass -if ( !jQuery.browser.safari ) { +//if ( !jQuery.browser.safari ) { test("$.ajax() - success callbacks", function() { expect( 8 ); @@ -144,7 +144,7 @@ test("$.ajax - dataType html", function() { foobar = null; testFoo = undefined; - + var verifyEvaluation = function() { ok( testFoo == "foo", 'Check if script was evaluated for datatype html' ); ok( foobar == "bar", 'Check if script src was evaluated for datatype html' ); @@ -163,11 +163,31 @@ test("$.ajax - dataType html", function() { }); test("serialize()", function() { - expect(1); - // ignore button, IE takes text content as value, not relevant for this test - equals( $(':input').not('button').serialize(), - 'action=Test&text2=Test&radio1=on&radio2=on&check=on&=on&hidden=&foo%5Bbar%5D=&name=name&=foobar&select1=&select2=3&select3=1&test=&id=', + expect(6); + + equals( $('#form').serialize(), + "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&select1=&select2=3&select3=0&select3=1", + 'Check form serialization as query string'); + + equals( $('#form :input').serialize(), + "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&select1=&select2=3&select3=0&select3=1", + 'Check input serialization as query string'); + + equals( $('#testForm').serialize(), + 'T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=', 'Check form serialization as query string'); + + equals( $('#testForm :input').serialize(), + 'T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=', + 'Check input serialization as query string'); + + equals( $('#form, #testForm').serialize(), + "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&select1=&select2=3&select3=0&select3=1&T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=", + 'Multiple form serialization as query string'); + + equals( $('#form, #testForm :input').serialize(), + "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&select1=&select2=3&select3=0&select3=1&T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=", + 'Mixed form/input serialization as query string'); }); test("$.param()", function() { @@ -211,7 +231,6 @@ test("pass-through request object", function() { /* Test disabled, too many simultaneous requests ok( $.get(url(target), success), "get" ); - ok( $.getIfModified(url(target), success), "getIfModified" ); ok( $.post(url(target), success), "post" ); ok( $.getScript(url("data/test.js"), success), "script" ); ok( $.getJSON(url("data/json_obj.js"), success), "json" ); @@ -312,15 +331,6 @@ test("$.get(String, Hash, Function) - parse xml and use text() on nodes", functi }); }); -test("$.getIfModified(String, Hash, Function)", function() { - expect(1); - stop(); - $.getIfModified(url("data/name.html"), function(msg) { - ok( /^ERROR/.test(msg), 'Check ifModified' ); - start(); - }); -}); - test("$.getScript(String, Function) - with callback", function() { expect(2); stop(); @@ -517,12 +527,12 @@ test("$.post(String, Hash, Function) - simple with xml", function() { }); }); -test("$.ajaxTimeout(Number) - with global timeout", function() { +test("$.ajaxSetup({timeout: Number}) - with global timeout", function() { stop(); var passed = 0; - $.ajaxTimeout(1000); + $.ajaxSetup({timeout: 1000}); var pass = function() { passed++; @@ -548,11 +558,13 @@ test("$.ajaxTimeout(Number) - with global timeout", function() { }); // reset timeout - $.ajaxTimeout(0); + $.ajaxSetup({timeout: 0}); }); -test("$.ajaxTimeout(Number) with localtimeout", function() { - stop(); $.ajaxTimeout(50); +test("$.ajaxSetup({timeout: Number}) with localtimeout", function() { + stop(); + $.ajaxSetup({timeout: 50}); + $.ajax({ type: "GET", timeout: 5000, @@ -566,8 +578,9 @@ test("$.ajaxTimeout(Number) with localtimeout", function() { start(); } }); + // reset timeout - $.ajaxTimeout(0); + $.ajaxSetup({timeout: 0}); }); test("$.ajax - simple get", function() { @@ -625,4 +638,4 @@ test("custom timeout does not set error message when timeout occurs, see #970", } -} +//}