Commit 7e8b8541 authored by Timo Tijhof's avatar Timo Tijhof Committed by Dave Methvin

Test: Clean up and fix misc issues

* Clean up testinit and testrunner

* Uncomment isLocal (at least make sure it is declared)

* Rephrase environment assertions to make sense if one reads
  them when they pass.

* Optimise an expensive loop that might be the cause of this
  in IE6: http://cl.ly/image/3f20053m112n
parent bb38f706
/*jshint multistr:true*/ /*jshint multistr:true */
var jQuery = this.jQuery || "jQuery", // For testing .noConflict() var jQuery = this.jQuery || "jQuery", // For testing .noConflict()
$ = this.$ || "$", $ = this.$ || "$",
originaljQuery = jQuery, originaljQuery = jQuery,
original$ = $, original$ = $,
hasPHP = true, hasPHP = true,
// Disable Ajax tests to reduce network strain
// Re-enabled (at least the variable should be declared)
isLocal = window.location.protocol === "file:",
amdDefined; amdDefined;
/** /**
...@@ -123,7 +126,7 @@ if ( document.createEvent ) { ...@@ -123,7 +126,7 @@ if ( document.createEvent ) {
* @result "data/test.php?foo=bar&10538358345554" * @result "data/test.php?foo=bar&10538358345554"
*/ */
function url( value ) { function url( value ) {
return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random()*100000); return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random() * 100000, 10);
} }
(function () { (function () {
...@@ -226,7 +229,7 @@ function url( value ) { ...@@ -226,7 +229,7 @@ function url( value ) {
jQuery( "<iframe/>" ).attr( "src", url( "./data/" + fileName ) ) jQuery( "<iframe/>" ).attr( "src", url( "./data/" + fileName ) )
).appendTo( "body" ); ).appendTo( "body" );
}); });
} };
}()); }());
// Sandbox start for great justice // Sandbox start for great justice
......
...@@ -123,7 +123,7 @@ function testSubproject( label, url, risTests ) { ...@@ -123,7 +123,7 @@ function testSubproject( label, url, risTests ) {
} }
fnTest.apply( this, arguments ); fnTest.apply( this, arguments );
} };
} }
} }
...@@ -167,8 +167,5 @@ QUnit.config.testTimeout = 20 * 1000; // 20 seconds ...@@ -167,8 +167,5 @@ QUnit.config.testTimeout = 20 * 1000; // 20 seconds
return; return;
} }
// (Temporarily) Disable Ajax tests to reduce network strain
// isLocal = QUnit.isLocal = true;
document.write("<scr" + "ipt src='http://swarm.jquery.org/js/inject.js?" + (new Date).getTime() + "'></scr" + "ipt>"); document.write("<scr" + "ipt src='http://swarm.jquery.org/js/inject.js?" + (new Date).getTime() + "'></scr" + "ipt>");
})(); })();
...@@ -2,8 +2,8 @@ module("core", { teardown: moduleTeardown }); ...@@ -2,8 +2,8 @@ module("core", { teardown: moduleTeardown });
test("Unit Testing Environment", function () { test("Unit Testing Environment", function () {
expect(2); expect(2);
ok( hasPHP, "Running Unit tests without PHP is unsupported! The AJAX tests won't run without it and don't expect all tests to pass without it!" ); ok( hasPHP, "Running in an environment with PHP support. The AJAX tests only run if the environment supports PHP!" );
ok( !isLocal, "Unit tests shouldn't be run from file://, especially in Chrome. If you must test from file:// with Chrome, run it with the --allow-file-access-from-files flag!" ); ok( !isLocal, "Unit tests are not ran from file:// (especially in Chrome. If you must test from file:// with Chrome, run it with the --allow-file-access-from-files flag!)" );
}); });
test("Basic requirements", function() { test("Basic requirements", function() {
...@@ -644,12 +644,12 @@ test("jQuery('html')", function() { ...@@ -644,12 +644,12 @@ test("jQuery('html')", function() {
var li = "<li>very large html string</li>"; var li = "<li>very large html string</li>";
var html = ["<ul>"]; var html = ["<ul>"];
for ( i = 0; i < 50000; i += 1 ) { for ( i = 0; i < 50000; i += 1 ) {
html.push(li); html[html.length] = li;
} }
html.push("</ul>"); html[html.length] = "</ul>";
html = jQuery(html.join(""))[0]; html = jQuery(html.join(""))[0];
equal( html.nodeName.toUpperCase(), "UL"); equal( html.nodeName.toLowerCase(), "ul");
equal( html.firstChild.nodeName.toUpperCase(), "LI"); equal( html.firstChild.nodeName.toLowerCase(), "li");
equal( html.childNodes.length, 50000 ); equal( html.childNodes.length, 50000 );
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment