aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFelix Nagel <info@felixnagel.com>2017-03-30 23:18:25 +0200
committerFelix Nagel <info@felixnagel.com>2017-03-30 23:18:25 +0200
commit4267e4283ca6259d5e7612c8dd66024f766b1595 (patch)
treece0cd1a7ae42d6f7a3c09c887dc2a0a16629b73d /tests
parent188550faff8baefff96e36b4094ad7fd00c91c45 (diff)
parent032ddc3349f625e0840aa8e266b5d8ebee994853 (diff)
downloadjquery-ui-4267e4283ca6259d5e7612c8dd66024f766b1595.tar.gz
jquery-ui-4267e4283ca6259d5e7612c8dd66024f766b1595.zip
Merge branch 'master' into datepicker
# Conflicts: # ui/i18n/datepicker-sv.js # ui/widgets/datepicker.js
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/bootstrap.js40
-rw-r--r--tests/lib/qunit.js5
-rw-r--r--tests/unit/resizable/options.js28
-rw-r--r--tests/unit/selectmenu/core.js26
-rw-r--r--tests/unit/spinner/core.js34
5 files changed, 112 insertions, 21 deletions
diff --git a/tests/lib/bootstrap.js b/tests/lib/bootstrap.js
index e846720cd..e3d344cec 100644
--- a/tests/lib/bootstrap.js
+++ b/tests/lib/bootstrap.js
@@ -1,5 +1,7 @@
( function() {
+var DEFAULT_JQUERY_VERSION = "1.12.4";
+
requirejs.config( {
paths: {
"cldr": "../../../external/cldrjs/cldr",
@@ -8,6 +10,7 @@ requirejs.config( {
"globalize-old": "../../../external/globalize-old/globalize",
"globalize-old/ja-JP": "../../../external/globalize-old/globalize.culture.ja-JP",
"jquery": jqueryUrl(),
+ "jquery-migrate": migrateUrl(),
"jquery-simulate": "../../../external/jquery-simulate/jquery.simulate",
"jshint": "../../../external/jshint/jshint",
"lib": "../../lib",
@@ -77,6 +80,10 @@ function requireTests( dependencies, noBackCompat ) {
dependencies.push( "testswarm" );
}
+ if ( parseUrl().migrate ) {
+ dependencies.push( "jquery-migrate" );
+ }
+
requireModules( dependencies, function( QUnit ) {
QUnit.start();
} );
@@ -91,21 +98,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 d9094723a..dd4a7f690 100644
--- a/tests/lib/qunit.js
+++ b/tests/lib/qunit.js
@@ -37,6 +37,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() {
diff --git a/tests/unit/resizable/options.js b/tests/unit/resizable/options.js
index f89682593..4080bac0e 100644
--- a/tests/unit/resizable/options.js
+++ b/tests/unit/resizable/options.js
@@ -434,11 +434,20 @@ QUnit.test( "zIndex, applied to all handles", function( assert ) {
} );
QUnit.test( "setOption handles", function( assert ) {
- assert.expect( 11 );
-
- var target = $( "<div></div>" ).resizable();
-
- function checkHandles( expectedHandles ) {
+ assert.expect( 15 );
+
+ var target = $( "<div></div>" ).resizable(),
+ target2 = $( "<div>" +
+ "<div class='ui-resizable-handle ui-resizable-e'></div>" +
+ "<div class='ui-resizable-handle ui-resizable-w'></div>" +
+ "</div>" ).resizable( {
+ handles: {
+ "e": "ui-resizable-e",
+ "w": "ui-resizable-w"
+ }
+ } );
+
+ function checkHandles( target, expectedHandles ) {
expectedHandles = $.map( expectedHandles, function( value ) {
return ".ui-resizable-" + value;
} );
@@ -451,13 +460,16 @@ QUnit.test( "setOption handles", function( assert ) {
} );
}
- checkHandles( [ "e", "s", "se" ] );
+ checkHandles( target, [ "e", "s", "se" ] );
target.resizable( "option", "handles", "n, w, nw" );
- checkHandles( [ "n", "w", "nw" ] );
+ checkHandles( target, [ "n", "w", "nw" ] );
target.resizable( "option", "handles", "s, w" );
- checkHandles( [ "s", "w" ] );
+ checkHandles( target, [ "s", "w" ] );
+
+ target2.resizable( "option", "handles", "e, s, w" );
+ checkHandles( target2, [ "e", "s", "w" ] );
} );
QUnit.test( "alsoResize + containment", function( assert ) {
diff --git a/tests/unit/selectmenu/core.js b/tests/unit/selectmenu/core.js
index a5bc68e0f..cef6dc5bf 100644
--- a/tests/unit/selectmenu/core.js
+++ b/tests/unit/selectmenu/core.js
@@ -376,4 +376,30 @@ QUnit.test( "Number pad input should change value", function( assert ) {
} );
} );
+QUnit.test( "Options with hidden attribute should not be rendered", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 1 );
+
+ var button, menu, options,
+ element = $( "#speed" );
+
+ element.find( "option" ).eq( 1 ).prop( "hidden", true );
+ element.selectmenu();
+ button = element.selectmenu( "widget" );
+ menu = element.selectmenu( "menuWidget" );
+
+ button.simulate( "focus" );
+ setTimeout( function() {
+ button.trigger( "click" );
+ options = menu.children()
+ .map( function() {
+ return $( this ).text();
+ } )
+ .get();
+ assert.deepEqual( options, [ "Slower", "Medium", "Fast", "Faster" ], "correct elements" );
+
+ ready();
+ } );
+} );
+
} );
diff --git a/tests/unit/spinner/core.js b/tests/unit/spinner/core.js
index 6d817134a..526f2ecf8 100644
--- a/tests/unit/spinner/core.js
+++ b/tests/unit/spinner/core.js
@@ -162,23 +162,39 @@ QUnit.test( "mouse click on up button, increases value not greater than max", fu
} );
QUnit.test( "mousewheel on input", function( assert ) {
- assert.expect( 4 );
+ var ready = assert.async();
+ assert.expect( 5 );
var element = $( "#spin" ).val( 0 ).spinner( {
step: 2
} );
- element.trigger( "mousewheel" );
- assert.equal( element.val(), 0, "mousewheel event without delta does not change value" );
+ element.simulate( "focus" );
+ setTimeout( step1 );
- element.trigger( "mousewheel", 1 );
- assert.equal( element.val(), 2 );
+ function step1() {
+ element.trigger( "mousewheel" );
+ assert.equal( element.val(), 0, "mousewheel event without delta does not change value" );
- element.trigger( "mousewheel", -0.2 );
- assert.equal( element.val(), 0 );
+ element.trigger( "mousewheel", 1 );
+ assert.equal( element.val(), 2, "delta 1" );
+
+ element.trigger( "mousewheel", -0.2 );
+ assert.equal( element.val(), 0, "delta -0.2" );
+
+ element.trigger( "mousewheel", -15 );
+ assert.equal( element.val(), -2, "delta -15" );
- element.trigger( "mousewheel", -15 );
- assert.equal( element.val(), -2 );
+ element.simulate( "blur" );
+ setTimeout( step2 );
+ }
+
+ function step2() {
+ element.trigger( "mousewheel", 1 );
+ assert.equal( element.val(), -2, "mousewheel when not focused" );
+
+ ready();
+ }
} );
QUnit.test( "reading HTML5 attributes", function( assert ) {