2015-04-03 19:21:16 +00:00
|
|
|
( function() {
|
|
|
|
|
2015-04-17 16:13:38 +00:00
|
|
|
requirejs.config({
|
2015-04-03 19:21:16 +00:00
|
|
|
paths: {
|
2015-04-06 23:46:15 +00:00
|
|
|
"globalize": "../../../external/globalize/globalize",
|
|
|
|
"globalize/ja-JP": "../../../external/globalize/globalize.culture.ja-JP",
|
2015-04-03 19:21:16 +00:00
|
|
|
"jquery": jqueryUrl(),
|
|
|
|
"jquery-simulate": "../../../external/jquery-simulate/jquery.simulate",
|
|
|
|
"jshint": "../../../external/jshint/jshint",
|
|
|
|
"lib": "../../lib",
|
|
|
|
"phantom-bridge": "../../../node_modules/grunt-contrib-qunit/phantomjs/bridge",
|
|
|
|
"qunit-assert-classes": "../../../external/qunit-assert-classes/qunit-assert-classes",
|
2015-04-08 13:15:23 +00:00
|
|
|
"qunit-assert-close": "../../../external/qunit-assert-close/qunit-assert-close",
|
2015-04-03 19:21:16 +00:00
|
|
|
"qunit": "../../../external/qunit/qunit",
|
2015-04-17 14:47:23 +00:00
|
|
|
"testswarm": "http://swarm.jquery.org/js/inject.js?" + (new Date()).getTime(),
|
2015-04-03 19:21:16 +00:00
|
|
|
"ui": "../../../ui"
|
|
|
|
},
|
|
|
|
shim: {
|
2015-04-06 23:46:15 +00:00
|
|
|
"globalize/ja-JP": [ "globalize" ],
|
2015-04-03 19:21:16 +00:00
|
|
|
"jquery-simulate": [ "jquery" ],
|
2015-04-08 13:15:23 +00:00
|
|
|
"qunit-assert-classes": [ "qunit" ],
|
2015-04-17 14:47:23 +00:00
|
|
|
"qunit-assert-close": [ "qunit" ],
|
|
|
|
"testswarm": [ "qunit" ]
|
2015-04-03 19:21:16 +00:00
|
|
|
}
|
2015-04-17 16:13:38 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Create a module that disables back compat for UI modules
|
|
|
|
define( "jquery-no-back-compat", [ "jquery" ], function( $ ) {
|
|
|
|
$.uiBackCompat = false;
|
|
|
|
|
|
|
|
return $;
|
|
|
|
} );
|
|
|
|
|
|
|
|
// Create a dummy bridge if we're not actually testing in PhantomJS
|
|
|
|
if ( !/PhantomJS/.test( navigator.userAgent ) ) {
|
|
|
|
define( "phantom-bridge", function() {} );
|
|
|
|
}
|
2015-04-03 19:21:16 +00:00
|
|
|
|
|
|
|
// Load all modules in series
|
|
|
|
function requireModules( dependencies, callback, modules ) {
|
|
|
|
if ( !dependencies.length ) {
|
|
|
|
if ( callback ) {
|
|
|
|
callback.apply( null, modules );
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !modules ) {
|
|
|
|
modules = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
var dependency = dependencies.shift();
|
|
|
|
require( [ dependency ], function( module ) {
|
|
|
|
modules.push( module );
|
|
|
|
requireModules( dependencies, callback, modules );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load a set of test file along with the required test infrastructure
|
2015-04-07 00:22:54 +00:00
|
|
|
function requireTests( dependencies, noBackCompat ) {
|
2015-04-03 19:21:16 +00:00
|
|
|
dependencies = [
|
2015-04-08 13:15:23 +00:00
|
|
|
"lib/qunit",
|
2015-04-07 00:22:54 +00:00
|
|
|
noBackCompat ? "jquery-no-back-compat" : "jquery",
|
2015-04-08 13:15:23 +00:00
|
|
|
"jquery-simulate"
|
2015-04-03 19:21:16 +00:00
|
|
|
].concat( dependencies );
|
|
|
|
|
2015-04-17 14:47:23 +00:00
|
|
|
// Load the TestSwarm injector, if necessary
|
|
|
|
if ( parseUrl().swarmURL ) {
|
|
|
|
dependencies.push( "testswarm" );
|
|
|
|
}
|
|
|
|
|
2015-04-03 19:21:16 +00:00
|
|
|
requireModules( dependencies, function( QUnit ) {
|
|
|
|
QUnit.start();
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Parse the URL into key/value pairs
|
|
|
|
function parseUrl() {
|
|
|
|
var data = {};
|
|
|
|
var parts = document.location.search.slice( 1 ).split( "&" );
|
|
|
|
var length = parts.length;
|
|
|
|
var i = 0;
|
|
|
|
var current;
|
|
|
|
|
|
|
|
for ( ; i < length; i++ ) {
|
|
|
|
current = parts[ i ].split( "=" );
|
|
|
|
data[ current[ 0 ] ] = current[ 1 ];
|
|
|
|
}
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
function jqueryUrl() {
|
|
|
|
var version = parseUrl().jquery;
|
|
|
|
var url;
|
|
|
|
|
|
|
|
if ( version === "git" || version === "git1" ) {
|
|
|
|
url = "http://code.jquery.com/jquery-" + version;
|
|
|
|
} else {
|
|
|
|
url = "../../../external/jquery-" + ( version || "1.11.2" ) + "/jquery";
|
|
|
|
}
|
|
|
|
|
|
|
|
return url;
|
2015-04-17 16:13:38 +00:00
|
|
|
}
|
2015-04-03 19:21:16 +00:00
|
|
|
|
|
|
|
// Load test modules based on data attributes
|
|
|
|
// - data-modules: list of test modules to load
|
|
|
|
// - data-widget: A widget to load test modules for
|
|
|
|
// - Automatically loads common, core, events, methods, and options
|
|
|
|
// - data-deprecated: Loads the deprecated test modules for a widget
|
2015-04-07 00:22:54 +00:00
|
|
|
// - data-no-back-compat: Set $.uiBackCompat to false
|
2015-04-03 19:21:16 +00:00
|
|
|
(function() {
|
|
|
|
|
|
|
|
// Find the script element
|
|
|
|
var scripts = document.getElementsByTagName( "script" );
|
|
|
|
var script = scripts[ scripts.length - 1 ];
|
|
|
|
|
|
|
|
// Read the modules
|
|
|
|
var modules = script.getAttribute( "data-modules" );
|
|
|
|
if ( modules ) {
|
|
|
|
modules = modules
|
|
|
|
.replace( /^\s+|\s+$/g, "" )
|
|
|
|
.split( /\s+/ );
|
|
|
|
} else {
|
|
|
|
modules = [];
|
|
|
|
}
|
|
|
|
var widget = script.getAttribute( "data-widget" );
|
2015-04-07 00:22:54 +00:00
|
|
|
var deprecated = !!script.getAttribute( "data-deprecated" );
|
|
|
|
var noBackCompat = !!script.getAttribute( "data-no-back-compat" );
|
|
|
|
|
2015-04-03 19:21:16 +00:00
|
|
|
if ( widget ) {
|
|
|
|
modules = modules.concat([
|
2015-04-07 14:55:52 +00:00
|
|
|
( deprecated ? "common-deprecated" : "common" ),
|
|
|
|
"core",
|
|
|
|
"events",
|
|
|
|
"methods",
|
|
|
|
"options"
|
2015-04-03 19:21:16 +00:00
|
|
|
]);
|
|
|
|
if ( deprecated ) {
|
2015-04-07 14:55:52 +00:00
|
|
|
modules = modules.concat( "deprecated" );
|
2015-04-03 19:21:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-17 16:13:38 +00:00
|
|
|
requireTests( modules, noBackCompat );
|
2015-04-03 19:21:16 +00:00
|
|
|
} )();
|
|
|
|
|
|
|
|
} )();
|