X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=test%2Fdata%2Ftestinit.js;h=a66f71d25f0bf909babdc9ffa546780c549daa91;hb=339708cda9985aeef947a28bec1354bdfcc2a358;hp=41aa396b470571b2d425f2cc6cc461cc2bc9e48c;hpb=8df82d2b04505a45408c2fcf22859a4c60af2e58;p=jquery.git
diff --git a/test/data/testinit.js b/test/data/testinit.js
index 41aa396..a66f71d 100644
--- a/test/data/testinit.js
+++ b/test/data/testinit.js
@@ -2,3 +2,46 @@ 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 [
, , ]
+ */
+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);
+}