Permalink
Browse files

Bringing some test suite changes back from jQuery.

  • Loading branch information...
jeresig committed Nov 10, 2009
1 parent a3e4cd4 commit 10aa61fe59213bb041a73446a651b163fe84f913
Showing with 85 additions and 955 deletions.
  1. +3 −0 .gitmodules
  2. +47 −0 test/data/testinit.js
  3. +8 −12 test/index.html
  4. +1 −0 test/qunit
  5. +0 −797 test/qunit/testrunner.js
  6. +0 −120 test/qunit/testsuite.css
  7. +26 −26 test/unit/selector.js
View
@@ -0,0 +1,3 @@
+[submodule "test/qunit"]
+ path = test/qunit
+ url = git://github.com/jquery/qunit.git
View
@@ -0,0 +1,47 @@
+var jQuery = this.jQuery || "jQuery", // For testing .noConflict()
+ $ = this.$ || "$",
+ originaljQuery = jQuery,
+ original$ = $;
+
+/**
+ * Returns an array of elements with the given IDs, eg.
+ * @example q("main", "foo", "bar")
+ * @result [<div id="main">, <span id="foo">, <input id="bar">]
+ */
+function q() {
+ var r = [];
+
+ for ( var i = 0; i < arguments.length; i++ ) {
+ r.push( document.getElementById( arguments[i] ) );
+ }
+
+ return r;
+}
+
+/**
+ * Asserts that a select matches the given IDs * @example t("Check for something", "//[a]", ["foo", "baar"]);
+ * @result returns true if "//[a]" return two elements with the IDs 'foo' and 'baa
+r'
+ */
+function t(a,b,c) {
+ var f = jQuery(b).get(), s = "";
+
+ for ( var i = 0; i < f.length; i++ ) {
+ s += (s && ",") + '"' + f[i].id + '"';
+ }
+
+ same(f, q.apply(q,c), a + " (" + b + ")");
+}
+
+/**
+ * Add random number to url to stop IE from caching
+ *
+ * @example url("data/test.html")
+ * @result "data/test.html?10538358428943"
+ *
+ * @example url("data/test.php?foo=bar")
+ * @result "data/test.php?foo=bar&10538358345554"
+ */
+function url(value) {
+ return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random()*100000);
+}
View
@@ -3,14 +3,8 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery Test Suite</title>
- <link rel="Stylesheet" media="screen" href="qunit/testsuite.css" />
+ <link rel="Stylesheet" media="screen" href="qunit/qunit/qunit.css" />
<!-- Includes -->
- <script type="text/javascript">
- var jQuery = this.jQuery || "jQuery", // For testing .noConflict()
- $ = this.$ || "$",
- originaljQuery = jQuery,
- original$ = $;
- </script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="../sizzle.js"></script>
<script>
@@ -19,15 +13,17 @@
jQuery.expr[":"] = jQuery.expr.filters;
jQuery.unique = Sizzle.uniqueSort;
</script>
- <script type="text/javascript" src="qunit/testrunner.js"></script>
+ <script type="text/javascript" src="data/testinit.js"></script>
+ <script type="text/javascript" src="qunit/qunit/qunit.js"></script>
<script type="text/javascript" src="data/testrunner.js"></script>
<script type="text/javascript" src="unit/selector.js"></script>
</head>
<body id="body">
- <h1 id="header">jQuery Test Suite</h1>
- <h2 id="banner"></h2>
- <h2 id="userAgent"></h2>
+ <h1 id="qunit-header">jQuery Test Suite</h1>
+ <h2 id="qunit-banner"></h2>
+ <div id="qunit-testrunner-toolbar"></div>
+ <h2 id="qunit-userAgent"></h2>
<!-- Test HTML -->
<div id="nothiddendiv" style="height:1px;background:white;" class="nothiddendiv">
@@ -225,6 +221,6 @@ <h2 id="userAgent"></h2>
<div id="fx-tests"></div>
</div>
- <ol id="tests"></ol>
+ <ol id="qunit-tests"></ol>
</body>
</html>
Submodule qunit added at 958c03
Oops, something went wrong.

0 comments on commit 10aa61f

Please sign in to comment.