aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/spinner
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2017-02-19 10:52:27 -0500
committerScott González <scott.gonzalez@gmail.com>2017-02-21 12:45:19 -0500
commita3b9129be19afabb3fa6b2fb913b85aab43f4652 (patch)
tree39063d55018265e896165afdb07c4c631af07fed /tests/unit/spinner
parent162377fba20f95fed81dde877833e5d432b246d1 (diff)
downloadjquery-ui-a3b9129be19afabb3fa6b2fb913b85aab43f4652.tar.gz
jquery-ui-a3b9129be19afabb3fa6b2fb913b85aab43f4652.zip
Spinner: Ignore `mousewheel` events when not focused
Fixes #15139 Closes gh-1794
Diffstat (limited to 'tests/unit/spinner')
-rw-r--r--tests/unit/spinner/core.js34
1 files changed, 25 insertions, 9 deletions
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 ) {