diff options
author | Eirik Sletteberg <eiriksletteberg@gmail.com> | 2016-12-04 21:57:28 +0100 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2017-02-06 08:23:18 -0500 |
commit | 4fa0267edc0e83352bed5f6f7cb66057c02cf81d (patch) | |
tree | a403badb2989e0f3ca78dcf690afb4cd56e7e901 /tests/lib | |
parent | c1f96f11cc763cceb2dce87b1d42ce1ca1709d31 (diff) | |
download | jquery-ui-4fa0267edc0e83352bed5f6f7cb66057c02cf81d.tar.gz jquery-ui-4fa0267edc0e83352bed5f6f7cb66057c02cf81d.zip |
Qunit: Add bootstrap config for running tests with jQuery Migrate
Closes gh-1774
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/bootstrap.js | 40 | ||||
-rw-r--r-- | tests/lib/qunit.js | 5 |
2 files changed, 41 insertions, 4 deletions
diff --git a/tests/lib/bootstrap.js b/tests/lib/bootstrap.js index 3d9cc3691..940cf553b 100644 --- a/tests/lib/bootstrap.js +++ b/tests/lib/bootstrap.js @@ -1,10 +1,13 @@ ( function() { +var DEFAULT_JQUERY_VERSION = "1.12.4"; + requirejs.config( { paths: { "globalize": "../../../external/globalize/globalize", "globalize/ja-JP": "../../../external/globalize/globalize.culture.ja-JP", "jquery": jqueryUrl(), + "jquery-migrate": migrateUrl(), "jquery-simulate": "../../../external/jquery-simulate/jquery.simulate", "jshint": "../../../external/jshint/jshint", "lib": "../../lib", @@ -68,6 +71,10 @@ function requireTests( dependencies, noBackCompat ) { dependencies.push( "testswarm" ); } + if ( parseUrl().migrate ) { + dependencies.push( "jquery-migrate" ); + } + requireModules( dependencies, function( QUnit ) { QUnit.start(); } ); @@ -82,21 +89,46 @@ function parseUrl() { var current; for ( ; i < length; i++ ) { - current = parts[ i ].split( "=" ); - data[ current[ 0 ] ] = current[ 1 ]; + if ( parts[ i ].match( "=" ) ) { + current = parts[ i ].split( "=" ); + data[ current[ 0 ] ] = current[ 1 ]; + } else { + data[ parts[ i ] ] = true + } } return data; } function jqueryUrl() { - var version = parseUrl().jquery; + var version = parseUrl().jquery || DEFAULT_JQUERY_VERSION; var url; if ( version === "git" ) { url = "http://code.jquery.com/jquery-" + version; } else { - url = "../../../external/jquery-" + ( version || "1.12.4" ) + "/jquery"; + url = "../../../external/jquery-" + version + "/jquery"; + } + + return url; +} + +function migrateUrl() { + var jqueryVersion = parseUrl().jquery || DEFAULT_JQUERY_VERSION; + var url; + + if ( jqueryVersion === "git" ) { + url = "http://code.jquery.com/jquery-migrate-git"; + } else if ( jqueryVersion[ 0 ] === "3" ) { + url = "../../../external/jquery-migrate-3.0.0/jquery-migrate"; + } else if ( jqueryVersion[ 0 ] === "1" || jqueryVersion[ 0 ] === "2" ) { + url = "../../../external/jquery-migrate-1.4.1/jquery-migrate"; + } else if ( jqueryVersion === "custom" ) { + if ( parseUrl().migrate ) { + throw new Error ( "Migrate not currently supported for custom build" ); + } + } else { + throw new Error( "No migrate version known for jQuery " + jqueryVersion ); } return url; diff --git a/tests/lib/qunit.js b/tests/lib/qunit.js index 15f3e96b1..c16d31154 100644 --- a/tests/lib/qunit.js +++ b/tests/lib/qunit.js @@ -36,6 +36,11 @@ QUnit.config.urlConfig.push( { tooltip: "Which jQuery Core version to test against" } ); +QUnit.config.urlConfig.push( { + id: "migrate", + label: "Enable jquery-migrate" +} ); + QUnit.reset = ( function( reset ) { return function() { |