]> source.dussan.org Git - jquery-ui.git/commitdiff
Draggable Tests: clarify scroll helpers.
authorMike Sherov <mike.sherov@gmail.com>
Sun, 20 Oct 2013 12:37:34 +0000 (08:37 -0400)
committerMike Sherov <mike.sherov@gmail.com>
Sun, 20 Oct 2013 12:37:34 +0000 (08:37 -0400)
tests/unit/draggable/draggable_options.js
tests/unit/draggable/draggable_test_helpers.js

index 27d53639f2cc389af25b96b6962b0d0893d24ecf..e18080a5bb4729a2e0cf853b4d222e72228f418f 100644 (file)
@@ -694,16 +694,16 @@ test( "{ helper: 'original' }, relative, with scroll offset on parent", function
 
        var element = $( "#draggable1" ).draggable({ helper: "original" });
 
-       TestHelpers.draggable.setScroll();
+       TestHelpers.draggable.setScroll( "#main" );
        TestHelpers.draggable.testScroll( element, "relative" );
 
-       TestHelpers.draggable.setScroll();
+       TestHelpers.draggable.setScroll( "#main" );
        TestHelpers.draggable.testScroll( element, "static" );
 
-       TestHelpers.draggable.setScroll();
+       TestHelpers.draggable.setScroll( "#main" );
        TestHelpers.draggable.testScroll( element, "absolute" );
 
-       TestHelpers.draggable.restoreScroll();
+       TestHelpers.draggable.restoreScroll( "#main" );
 });
 
 test( "{ helper: 'original' }, relative, with scroll offset on root", function() {
@@ -711,16 +711,16 @@ test( "{ helper: 'original' }, relative, with scroll offset on root", function()
 
        var element = $( "#draggable1" ).draggable({ helper: "original" });
 
-       TestHelpers.draggable.setScroll( "root" );
+       TestHelpers.draggable.setScroll( document );
        TestHelpers.draggable.testScroll( element, "relative" );
 
-       TestHelpers.draggable.setScroll( "root" );
+       TestHelpers.draggable.setScroll( document );
        TestHelpers.draggable.testScroll( element, "static" );
 
-       TestHelpers.draggable.setScroll( "root" );
+       TestHelpers.draggable.setScroll( document );
        TestHelpers.draggable.testScroll( element, "absolute" );
 
-       TestHelpers.draggable.restoreScroll( "root" );
+       TestHelpers.draggable.restoreScroll( document );
 });
 
 test( "{ helper: 'original' }, relative, with scroll offset on root and parent", function() {
@@ -728,20 +728,20 @@ test( "{ helper: 'original' }, relative, with scroll offset on root and parent",
 
        var element = $( "#draggable1" ).draggable({ helper: "original" });
 
-       TestHelpers.draggable.setScroll();
-       TestHelpers.draggable.setScroll( "root" );
+       TestHelpers.draggable.setScroll( "#main" );
+       TestHelpers.draggable.setScroll( document );
        TestHelpers.draggable.testScroll( element, "relative" );
 
-       TestHelpers.draggable.setScroll();
-       TestHelpers.draggable.setScroll( "root" );
+       TestHelpers.draggable.setScroll( "#main" );
+       TestHelpers.draggable.setScroll( document );
        TestHelpers.draggable.testScroll( element, "static" );
 
-       TestHelpers.draggable.setScroll();
-       TestHelpers.draggable.setScroll( "root" );
+       TestHelpers.draggable.setScroll( "#main" );
+       TestHelpers.draggable.setScroll( document );
        TestHelpers.draggable.testScroll( element, "absolute" );
 
-       TestHelpers.draggable.restoreScroll();
-       TestHelpers.draggable.restoreScroll( "root" );
+       TestHelpers.draggable.restoreScroll( "#main" );
+       TestHelpers.draggable.restoreScroll( document );
 });
 
 test( "{ helper: 'original' }, absolute, with scroll offset on parent", function() {
@@ -749,16 +749,16 @@ test( "{ helper: 'original' }, absolute, with scroll offset on parent", function
 
        var element = $( "#draggable1" ).css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" });
 
-       TestHelpers.draggable.setScroll();
+       TestHelpers.draggable.setScroll( "#main" );
        TestHelpers.draggable.testScroll( element, "relative" );
 
-       TestHelpers.draggable.setScroll();
+       TestHelpers.draggable.setScroll( "#main" );
        TestHelpers.draggable.testScroll( element, "static" );
 
-       TestHelpers.draggable.setScroll();
+       TestHelpers.draggable.setScroll( "#main" );
        TestHelpers.draggable.testScroll( element, "absolute" );
 
-       TestHelpers.draggable.restoreScroll();
+       TestHelpers.draggable.restoreScroll( "#main" );
 });
 
 test( "{ helper: 'original' }, absolute, with scroll offset on root", function() {
@@ -766,16 +766,16 @@ test( "{ helper: 'original' }, absolute, with scroll offset on root", function()
 
        var element = $( "#draggable1" ).css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" });
 
-       TestHelpers.draggable.setScroll( "root" );
+       TestHelpers.draggable.setScroll( document );
        TestHelpers.draggable.testScroll( element, "relative" );
 
-       TestHelpers.draggable.setScroll( "root" );
+       TestHelpers.draggable.setScroll( document );
        TestHelpers.draggable.testScroll( element, "static" );
 
-       TestHelpers.draggable.setScroll( "root" );
+       TestHelpers.draggable.setScroll( document );
        TestHelpers.draggable.testScroll( element, "absolute" );
 
-       TestHelpers.draggable.restoreScroll( "root" );
+       TestHelpers.draggable.restoreScroll( document );
 });
 
 test( "{ helper: 'original' }, absolute, with scroll offset on root and parent", function() {
@@ -783,20 +783,20 @@ test( "{ helper: 'original' }, absolute, with scroll offset on root and parent",
 
        var element = $( "#draggable1" ).css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" });
 
-       TestHelpers.draggable.setScroll();
-       TestHelpers.draggable.setScroll( "root" );
+       TestHelpers.draggable.setScroll( "#main" );
+       TestHelpers.draggable.setScroll( document );
        TestHelpers.draggable.testScroll( element, "relative" );
 
-       TestHelpers.draggable.setScroll();
-       TestHelpers.draggable.setScroll( "root" );
+       TestHelpers.draggable.setScroll( "#main" );
+       TestHelpers.draggable.setScroll( document );
        TestHelpers.draggable.testScroll( element, "static" );
 
-       TestHelpers.draggable.setScroll();
-       TestHelpers.draggable.setScroll( "root" );
+       TestHelpers.draggable.setScroll( "#main" );
+       TestHelpers.draggable.setScroll( document );
        TestHelpers.draggable.testScroll( element, "absolute" );
 
-       TestHelpers.draggable.restoreScroll();
-       TestHelpers.draggable.restoreScroll( "root" );
+       TestHelpers.draggable.restoreScroll( "#main" );
+       TestHelpers.draggable.restoreScroll( document );
 });
 
 test( "{ helper: 'original' }, fixed, with scroll offset on parent", function() {
@@ -804,16 +804,16 @@ test( "{ helper: 'original' }, fixed, with scroll offset on parent", function()
 
        var element = $( "#draggable1" ).css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" });
 
-       TestHelpers.draggable.setScroll();
+       TestHelpers.draggable.setScroll( "#main" );
        TestHelpers.draggable.testScroll( element, "relative" );
 
-       TestHelpers.draggable.setScroll();
+       TestHelpers.draggable.setScroll( "#main" );
        TestHelpers.draggable.testScroll( element, "static" );
 
-       TestHelpers.draggable.setScroll();
+       TestHelpers.draggable.setScroll( "#main" );
        TestHelpers.draggable.testScroll( element, "absolute" );
 
-       TestHelpers.draggable.restoreScroll();
+       TestHelpers.draggable.restoreScroll( "#main" );
 });
 
 test( "{ helper: 'original' }, fixed, with scroll offset on root", function() {
@@ -821,16 +821,16 @@ test( "{ helper: 'original' }, fixed, with scroll offset on root", function() {
 
        var element = $( "#draggable1" ).css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" });
 
-       TestHelpers.draggable.setScroll( "root" );
+       TestHelpers.draggable.setScroll( document );
        TestHelpers.draggable.testScroll( element, "relative" );
 
-       TestHelpers.draggable.setScroll( "root" );
+       TestHelpers.draggable.setScroll( document );
        TestHelpers.draggable.testScroll( element, "static" );
 
-       TestHelpers.draggable.setScroll( "root" );
+       TestHelpers.draggable.setScroll( document );
        TestHelpers.draggable.testScroll( element, "absolute" );
 
-       TestHelpers.draggable.restoreScroll( "root" );
+       TestHelpers.draggable.restoreScroll( document );
 });
 
 test( "{ helper: 'original' }, fixed, with scroll offset on root and parent", function() {
@@ -838,20 +838,20 @@ test( "{ helper: 'original' }, fixed, with scroll offset on root and parent", fu
 
        var element = $( "#draggable1" ).css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" });
 
-       TestHelpers.draggable.setScroll();
-       TestHelpers.draggable.setScroll( "root" );
+       TestHelpers.draggable.setScroll( "#main" );
+       TestHelpers.draggable.setScroll( document );
        TestHelpers.draggable.testScroll( element, "relative" );
 
-       TestHelpers.draggable.setScroll();
-       TestHelpers.draggable.setScroll( "root" );
+       TestHelpers.draggable.setScroll( "#main" );
+       TestHelpers.draggable.setScroll( document );
        TestHelpers.draggable.testScroll( element, "static" );
 
-       TestHelpers.draggable.setScroll();
-       TestHelpers.draggable.setScroll( "root" );
+       TestHelpers.draggable.setScroll( "#main" );
+       TestHelpers.draggable.setScroll( document );
        TestHelpers.draggable.testScroll( element, "absolute" );
 
-       TestHelpers.draggable.restoreScroll();
-       TestHelpers.draggable.restoreScroll( "root" );
+       TestHelpers.draggable.restoreScroll( "#main" );
+       TestHelpers.draggable.restoreScroll( document );
 });
 
 test( "{ helper: 'clone' }, absolute", function() {
@@ -873,7 +873,7 @@ test( "{ helper: 'clone' }, absolute", function() {
 test( "{ helper: 'clone' }, absolute with scroll offset on parent", function() {
        expect( 3 );
 
-       TestHelpers.draggable.setScroll();
+       TestHelpers.draggable.setScroll( "#main" );
        var helperOffset = null,
                origOffset = null,
                element = $( "#draggable1" ).draggable({
@@ -907,13 +907,13 @@ test( "{ helper: 'clone' }, absolute with scroll offset on parent", function() {
        });
        deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
 
-       TestHelpers.draggable.restoreScroll();
+       TestHelpers.draggable.restoreScroll( "#main" );
 });
 
 test( "{ helper: 'clone' }, absolute with scroll offset on root", function() {
        expect( 3 );
 
-       TestHelpers.draggable.setScroll( "root" );
+       TestHelpers.draggable.setScroll( document );
        var helperOffset = null,
                origOffset = null,
                element = $( "#draggable1" ).draggable({
@@ -947,14 +947,14 @@ test( "{ helper: 'clone' }, absolute with scroll offset on root", function() {
        });
        deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
 
-       TestHelpers.draggable.restoreScroll( "root" );
+       TestHelpers.draggable.restoreScroll( document );
 });
 
 test( "{ helper: 'clone' }, absolute with scroll offset on root and parent", function() {
        expect( 3 );
 
-       TestHelpers.draggable.setScroll( "root" );
-       TestHelpers.draggable.setScroll();
+       TestHelpers.draggable.setScroll( document );
+       TestHelpers.draggable.setScroll( "#main" );
 
        var helperOffset = null,
                origOffset = null,
@@ -989,8 +989,8 @@ test( "{ helper: 'clone' }, absolute with scroll offset on root and parent", fun
        });
        deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
 
-       TestHelpers.draggable.restoreScroll( "root" );
-       TestHelpers.draggable.restoreScroll();
+       TestHelpers.draggable.restoreScroll( document );
+       TestHelpers.draggable.restoreScroll( "#main" );
 });
 
 test( "{ opacity: 0.5 }", function() {
index 00ff08d3e0c6d696bdaa36cc75af54b9f3bbf3dd..c17992b98011ee0fda0d38b42e854e02a44bef0a 100644 (file)
@@ -38,18 +38,10 @@ TestHelpers.draggable = {
                $( "#main" ).css( "position", oldPosition );
        },
        restoreScroll: function( what ) {
-               if( what ) {
-                       $( document ).scrollTop( 0 ).scrollLeft( 0 );
-               } else {
-                       $( "#main" ).scrollTop( 0 ).scrollLeft( 0 );
-               }
+               $( what ).scrollTop( 0 ).scrollLeft( 0 );
        },
        setScroll: function( what ) {
-               if( what ) {
-                       $( document ).scrollTop( 100 ).scrollLeft( 100 );
-               } else {
-                       $( "#main" ).scrollTop( 100 ).scrollLeft( 100 );
-               }
+               $( what ).scrollTop( 100 ).scrollLeft( 100 );
        },
        border: function( el, side ) {
                return parseInt( el.css( "border-" + side + "-width" ), 10 ) || 0;