aboutsummaryrefslogtreecommitdiffstats
path: root/test/data/testinit.js
diff options
context:
space:
mode:
authorTimmy Willison <timmywillisn@gmail.com>2013-09-06 16:23:20 -0400
committerTimmy Willison <timmywillisn@gmail.com>2013-09-06 16:23:20 -0400
commite563cd3414930bc4a5b4bc47c67c3a917b44c160 (patch)
treedbd7a97360e8045c538306016100c7b30b10ee19 /test/data/testinit.js
parent6535cc599e4d7ccb80cb1d83f20344d71702516b (diff)
downloadjquery-e563cd3414930bc4a5b4bc47c67c3a917b44c160.tar.gz
jquery-e563cd3414930bc4a5b4bc47c67c3a917b44c160.zip
Move test loader to testinit.js. Fix race condition with dependency loading.
Diffstat (limited to 'test/data/testinit.js')
-rw-r--r--test/data/testinit.js67
1 files changed, 67 insertions, 0 deletions
diff --git a/test/data/testinit.js b/test/data/testinit.js
index 8cb57d5f5..f7d8f2c0c 100644
--- a/test/data/testinit.js
+++ b/test/data/testinit.js
@@ -254,3 +254,70 @@ this.testIframeWithCallback = function( title, fileName, func ) {
});
};
this.iframeCallback = undefined;
+
+// Tests are always loaded async
+QUnit.config.autostart = false;
+this.loadTests = function() {
+ var loadSwarm,
+ url = window.location.search,
+ tests = [
+ "data/testrunner.js",
+ "unit/core.js",
+ "unit/callbacks.js",
+ "unit/deferred.js",
+ "unit/support.js",
+ "unit/data.js",
+ "unit/queue.js",
+ "unit/attributes.js",
+ "unit/event.js",
+ "unit/selector.js",
+ "unit/traversing.js",
+ "unit/manipulation.js",
+ "unit/wrap.js",
+ "unit/css.js",
+ "unit/serialize.js",
+ "unit/ajax.js",
+ "unit/effects.js",
+ "unit/offset.js",
+ "unit/dimensions.js"
+ ];
+ url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + "swarmURL=".length ) );
+ loadSwarm = url && url.indexOf("http") === 0;
+
+ // Ensure load order (to preserve test numbers)
+ (function loadDep() {
+ var dep = tests.shift();
+ if ( dep ) {
+ require( [ dep ], loadDep );
+ } else {
+ // Subproject tests must be last because they replace our test fixture
+ testSubproject( "Sizzle", "../bower_components/sizzle/test/", /^unit\/.*\.js$/, function() {
+ // Call load to build module filter select element
+ QUnit.load();
+
+ // Load the TestSwarm listener if swarmURL is in the address.
+ if ( loadSwarm ) {
+ require( [ "http://swarm.jquery.org/js/inject.js?" + (new Date()).getTime() ], function() {
+ QUnit.start();
+ });
+ } else {
+ QUnit.start();
+ }
+
+ /**
+ * Run in noConflict mode
+ */
+ jQuery.noConflict();
+
+ // Expose Sizzle for Sizzle's selector tests
+ // We remove Sizzle's globalization in jQuery
+ window.Sizzle = window.Sizzle || jQuery.find;
+
+ // For checking globals pollution despite auto-created globals in various environments
+ supportjQuery.each( [ jQuery.expando, "getInterface", "Packages", "java", "netscape" ], function( i, name ) {
+ window[ name ] = window[ name ];
+ });
+ });
+ }
+ })();
+};