]> source.dussan.org Git - jquery.git/commitdiff
Refactored and fixed test suite to run async tests
authorJörn Zaefferer <joern.zaefferer@gmail.com>
Sat, 30 Sep 2006 14:34:49 +0000 (14:34 +0000)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Sat, 30 Sep 2006 14:34:49 +0000 (14:34 +0000)
build/test/data/json.php [new file with mode: 0644]
build/test/data/name.php [new file with mode: 0644]
build/test/data/test.js [new file with mode: 0644]
build/test/data/testrunner.js
build/test/index.html
build/test/test.js

diff --git a/build/test/data/json.php b/build/test/data/json.php
new file mode 100644 (file)
index 0000000..31668cf
--- /dev/null
@@ -0,0 +1,8 @@
+<?php\r
+$json = $_REQUEST['json'];\r
+if($json) {\r
+       echo '[ {"name": "John", "age": 21}, {"name": "Peter", "age": 25 } ]';\r
+} else {\r
+       echo '{ "data": {"lang": "en", "length": 25} }';\r
+}\r
+?>
\ No newline at end of file
diff --git a/build/test/data/name.php b/build/test/data/name.php
new file mode 100644 (file)
index 0000000..a287fc9
--- /dev/null
@@ -0,0 +1,22 @@
+<?php\r
+$wait = $_REQUEST['wait'];\r
+if($wait) {\r
+       sleep($wait);\r
+}\r
+$xml = $_REQUEST['xml'];\r
+if($xml) {\r
+       header("Content-type: text/xml");\r
+       eval("\$result = $xml;");\r
+       echo "<math><calculation>$xml</calculation><result>$result</result></math>";\r
+       die();\r
+}\r
+$name = $_REQUEST['name'];\r
+if($name == 'foo') {\r
+       echo "bar";\r
+       die();\r
+} else if($name == 'peter') {\r
+       echo "pan";\r
+       die();\r
+}\r
+echo "ERROR";\r
+?>
\ No newline at end of file
diff --git a/build/test/data/test.js b/build/test/data/test.js
new file mode 100644 (file)
index 0000000..2764fe1
--- /dev/null
@@ -0,0 +1 @@
+foobar = "bar";\r
index db97215bee2e50d4915ed1cdb932ed5136315690..11921f9c783eb9e10bb109c9246562db438557b4 100644 (file)
@@ -50,8 +50,8 @@ function runTest(tests) {
 }
 
 function test(name, callback) {
-       Test = [];
        synchronize(function() {
+               Test = [];
                try {
                        callback();
                } catch(e) {
index 2124948a6c42f40051be842026dfbf0bcdfa5b7c..048eec17cb795bcd973e536ca57ae8b774183a0e 100644 (file)
@@ -34,9 +34,9 @@
                <p id="first">Try them out:</p>\r
                <ul id="firstUL"></ul>
                <ol id="empty"></ol>
-               <form id="form" action="formaction">
-                       <input type="text" value="Test" name="action" id="text1"/>
-                       <input type="text" value="Test" id="text2" disabled="disabled"/>
+               <form id="form" action="formaction">\r
+                       <input type="text" name="action" value="Test" id="text1"/>
+                       <input type="text" name="text2" value="Test" id="text2" disabled="disabled"/>
                        <input type="radio" name="radio1" id="radio1"/>
 
                        <input type="radio" name="radio2" id="radio2" checked/>
@@ -48,6 +48,8 @@
                        \r
                        <input type="text" id="name" name="name" value="name" />\r
                        \r
+                       <button id="button" name="button">Button</button>\r
+                       \r
                        <textarea id="area1">foobar</textarea>\r
                        \r
                        <select name="select1" id="select1">\r
index 0a2b0427c2838e13f3b00a5cf33ebd1f6ca2d474..4a6f0c2f60cfbcc3ad4fcdbb6c47c8891f3db3b2 100644 (file)
@@ -28,7 +28,12 @@ for ( var i = 0; i < jq.length; i++ ) {
        if ( jq[i].tests.length > 0 ) {
                var method = jq[i];
                var name = addParams(method.name, method.params);
-               testFile[testFile.length] = addTestWrapper(name, method.tests.join("\n").decode());
+               for(var j = 0; j < method.tests.length; j++) {
+                       if(j > 0) {
+                               name += "x";
+                       }
+                       testFile[testFile.length] = addTestWrapper(name, method.tests[j].decode()) + "\n";
+               }
        }
 }