aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Sherov <mike.sherov@gmail.com>2014-02-17 22:10:29 -0500
committerMike Sherov <mike.sherov@gmail.com>2014-02-18 12:48:06 -0500
commitdc1e63b4324e55fd0d120ec250a5f32f647dffdd (patch)
treeb0c2fcf0f631ddef6c2112143fd14bddfa6ae16d
parentf1025298ccecb48f429a3a411e0ebd9b70fffa8b (diff)
downloadjquery-ui-dc1e63b4324e55fd0d120ec250a5f32f647dffdd.tar.gz
jquery-ui-dc1e63b4324e55fd0d120ec250a5f32f647dffdd.zip
Draggable Tests: fix IE scroll tests affected by focus issues.
Calling element.focus() causes scroll in IE. In order to correctly test scroll behavior, we must calculate scrollTop on the drag event, before .focus is called.
-rw-r--r--tests/unit/draggable/draggable_options.js17
1 files changed, 12 insertions, 5 deletions
diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js
index eba6c4731..4cebe4dfb 100644
--- a/tests/unit/draggable/draggable_options.js
+++ b/tests/unit/draggable/draggable_options.js
@@ -835,7 +835,8 @@ test( "scroll, scrollSensitivity, and scrollSpeed", function() {
TestHelpers.draggable.setScrollable( "#main", false );
- var viewportHeight = $( window ).height(),
+ var currentScrollTop,
+ viewportHeight = $( window ).height(),
element = $( "#draggable1" ).draggable({ scroll: true }).appendTo( "#qunit-fixture" ),
scrollSensitivity = element.draggable( "option", "scrollSensitivity" ),
scrollSpeed = element.draggable( "option", "scrollSpeed" );
@@ -845,14 +846,16 @@ test( "scroll, scrollSensitivity, and scrollSpeed", function() {
left: 1
});
+ $( element ).one( "drag", function() {
+ equal( $( window ).scrollTop(), 0, "scroll: true doesn't scroll when the element is dragged outside of scrollSensitivity" );
+ });
+
element.simulate( "drag", {
dx: 1,
y: viewportHeight - scrollSensitivity - 1,
moves: 1
});
- ok( $( window ).scrollTop() === 0, "scroll: true doesn't scroll when the element is dragged outside of scrollSensitivity" );
-
element.draggable( "option", "scrollSensitivity", scrollSensitivity + 10 );
element.offset({
@@ -860,14 +863,18 @@ test( "scroll, scrollSensitivity, and scrollSpeed", function() {
left: 1
});
+ currentScrollTop = $( window ).scrollTop();
+
+ $( element ).one( "drag", function() {
+ ok( $( window ).scrollTop() - currentScrollTop, scrollSpeed, "scroll: true scrolls when the element is dragged within scrollSensitivity" );
+ });
+
element.simulate( "drag", {
dx: 1,
y: viewportHeight - scrollSensitivity - 1,
moves: 1
});
- ok( $( window ).scrollTop() === scrollSpeed, "scroll: true scrolls when the element is dragged within scrollSensitivity" );
-
TestHelpers.draggable.restoreScroll( document );
});