aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
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/unit
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/unit')
-rw-r--r--tests/unit/resizable/options.js28
-rw-r--r--tests/unit/selectmenu/core.js26
-rw-r--r--tests/unit/spinner/core.js34
3 files changed, 71 insertions, 17 deletions
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 ) {