Skip to content

Commit

Permalink
Bringing some test suite changes back from jQuery.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeresig committed Nov 10, 2009
1 parent a3e4cd4 commit 10aa61f
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 955 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
@@ -0,0 +1,3 @@
[submodule "test/qunit"]
path = test/qunit
url = git://github.com/jquery/qunit.git
47 changes: 47 additions & 0 deletions test/data/testinit.js
@@ -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);
}
20 changes: 8 additions & 12 deletions test/index.html
Expand Up @@ -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>
Expand All @@ -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">
Expand Down Expand Up @@ -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>
1 change: 1 addition & 0 deletions test/qunit
Submodule qunit added at 958c03

0 comments on commit 10aa61f

Please sign in to comment.