From 5469442ad3e1101d1a3444357276baa7aad8985f Mon Sep 17 00:00:00 2001 From: John Bender Date: Tue, 20 Dec 2011 15:01:28 -0800 Subject: [PATCH] async test library load helper --- tests/jquery.testHelper.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/jquery.testHelper.js b/tests/jquery.testHelper.js index d39ae983..f80a0b9c 100644 --- a/tests/jquery.testHelper.js +++ b/tests/jquery.testHelper.js @@ -4,6 +4,34 @@ (function( $ ) { $.testHelper = { + asyncLoad: function( opts ) { + var baseUrl = opts.baseUrl || "../../../js"; + + // stop qunit from running the tests until everything is in the page + QUnit.config.autostart = false; + + // set the baseUrl to the js dir or the default + require({ + baseUrl: baseUrl + }); + + // require the libs required to pass the test suite + require( opts.libs, function() { + + // init the mobile library + require( ["jquery.mobile.init"], function() { + + // reset the base dir to the current directory for including the test libs + require({ + baseUrl: location.pathname + }); + + // after everything is inplace start the test suite + require( opts.testLibs, QUnit.start); + }); + }); + }, + excludeFileProtocol: function(callback){ var message = "Tests require script reload and cannot be run via file: protocol";