summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/ajax/jquery/test/test.js
diff options
context:
space:
mode:
Diffstat (limited to 'dom/tests/mochitest/ajax/jquery/test/test.js')
-rw-r--r--dom/tests/mochitest/ajax/jquery/test/test.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/dom/tests/mochitest/ajax/jquery/test/test.js b/dom/tests/mochitest/ajax/jquery/test/test.js
new file mode 100644
index 0000000000..e76b795a2c
--- /dev/null
+++ b/dom/tests/mochitest/ajax/jquery/test/test.js
@@ -0,0 +1,41 @@
+load( "build/js/writeFile.js", "build/js/parse.js" );
+
+function addParams(name, params) {
+ if(params.length > 0) {
+ name += "(";
+ for ( var i = 0; i < params.length; i++) {
+ name += params[i].type + ", ";
+ }
+ return name.substring(0, name.length - 2) + ")";
+ } else {
+ return name + "()";
+ }
+}
+function addTestWrapper(name, test) {
+ return 'test("' + name + '", function() {\n' + test + '\n});';
+}
+
+var dir = arguments[1];
+var jq = parse( read(arguments[0]) );
+
+var testFile = [];
+
+String.prototype.decode = function() {
+ return this.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
+};
+
+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);
+ for(var j = 0; j < method.tests.length; j++) {
+ if(j > 0) {
+ name += "x";
+ }
+ testFile[testFile.length] = addTestWrapper(name, method.tests[j].decode()) + "\n";
+ }
+ }
+}
+
+var indexFile = readFile( "build/test/index.html" );
+writeFile( dir + "/index.html", indexFile.replace( /{TESTS}/g, testFile.join("\n") ) );