aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorMike Sherov <mike.sherov@gmail.com>2013-10-19 11:12:35 -0400
committerMike Sherov <mike.sherov@gmail.com>2013-10-19 18:48:04 -0400
commit67fd40eda7a7f4a9e48afe09593c20bd0e0f9c6f (patch)
treee6ef0d4af2236b17128f6fdd5571dbae1a0332dd /tests/unit
parent52307ebadbca3f403549140e1d34f08bc07bf8ce (diff)
downloadjquery-ui-67fd40eda7a7f4a9e48afe09593c20bd0e0f9c6f.tar.gz
jquery-ui-67fd40eda7a7f4a9e48afe09593c20bd0e0f9c6f.zip
Tests: extract TestHelpers.forceScrollableWindow for tests that need the window to scroll
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/draggable/draggable_core.js22
-rw-r--r--tests/unit/selectable/selectable_events.js6
-rw-r--r--tests/unit/testsuite.js7
3 files changed, 15 insertions, 20 deletions
diff --git a/tests/unit/draggable/draggable_core.js b/tests/unit/draggable/draggable_core.js
index 0389ea9ee..5f1e173bf 100644
--- a/tests/unit/draggable/draggable_core.js
+++ b/tests/unit/draggable/draggable_core.js
@@ -118,14 +118,11 @@ test( "#6258: not following mouse when scrolled and using overflow-y: scroll", f
.scrollLeft( 0 );
}
}),
- contentToForceScroll = $( "<div>" ).css({
- height: "10000px",
- width: "10000px"
- }),
oldOverflowY = $( "html" ).css( "overflow-y" ),
oldOverflowX = $( "html" ).css( "overflow-x" );
- contentToForceScroll.appendTo( "#qunit-fixture" );
+ TestHelpers.forceScrollableWindow();
+
$( "html" )
.css( "overflow-y", "scroll" )
.css( "overflow-x", "scroll" )
@@ -148,13 +145,10 @@ test( "#9315: Draggable: jumps down with offset of scrollbar", function() {
equal( ui.position.top, 11, "top position is correct when position is absolute" );
$( "html" ).scrollTop( 0 ).scrollLeft( 0 );
}
- }),
- contentToForceScroll = $( "<div>" ).css({
- height: "10000px",
- width: "10000px"
});
- contentToForceScroll.appendTo( "#qunit-fixture" );
+ TestHelpers.forceScrollableWindow();
+
$( "html" ).scrollTop( 300 ).scrollLeft( 300 );
element.simulate( "drag", {
@@ -178,13 +172,11 @@ test( "#5009: scroll not working with parent's position fixed", function() {
equal( ui.position.top, 10, "top position is correct when parent position is fixed" );
$( document ).scrollTop( 0 ).scrollLeft( 0 );
}
- }),
- contentToForceScroll = $( "<div>" ).css({
- height: "20000px",
- width: "20000px"
});
- $( "#qunit-fixture" ).append( contentToForceScroll );
+
+ TestHelpers.forceScrollableWindow();
+
$( "#wrapper" ).css( "position", "fixed" );
element.simulate( "drag", {
diff --git a/tests/unit/selectable/selectable_events.js b/tests/unit/selectable/selectable_events.js
index ae35fa3ce..2cb99f49c 100644
--- a/tests/unit/selectable/selectable_events.js
+++ b/tests/unit/selectable/selectable_events.js
@@ -40,12 +40,8 @@ test( "mousedown: initial position of helper", function() {
var helperOffset,
element = $( "#selectable1" ).selectable(),
- contentToForceScroll = $( "<div>" ).css({
- height: "10000px",
- width: "10000px"
- });
+ contentToForceScroll = TestHelpers.forceScrollableWindow( "body" );
- contentToForceScroll.appendTo( "body" );
$( window ).scrollTop( 100 ).scrollLeft( 100 );
element.simulate( "mousedown", {
diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js
index 83d69d2d9..13daa7e66 100644
--- a/tests/unit/testsuite.js
+++ b/tests/unit/testsuite.js
@@ -191,6 +191,13 @@ TestHelpers.onFocus= function( element, onFocus ) {
element.bind( "focus", fn )[ 0 ].focus();
};
+TestHelpers.forceScrollableWindow = function( appendTo ) {
+ return $( "<div>" ).css({
+ height: "10000px",
+ width: "10000px"
+ }).appendTo( appendTo || "#qunit-fixture" );
+};
+
/*
* Taken from https://github.com/jquery/qunit/tree/master/addons/close-enough
*/