]> source.dussan.org Git - jquery-ui.git/commitdiff
Draggable Tests: make sure offset tests are actually testing offsets
authorMike Sherov <mike.sherov@gmail.com>
Sat, 19 Oct 2013 19:47:13 +0000 (15:47 -0400)
committerMike Sherov <mike.sherov@gmail.com>
Sat, 19 Oct 2013 22:53:00 +0000 (18:53 -0400)
tests/unit/draggable/draggable.html
tests/unit/draggable/draggable_options.js
tests/unit/draggable/draggable_test_helpers.js

index 3d1d3326e02d7bc0de0ca8ff3619dcbd91318304..17f9745a6c4f258f8293ee37b3880cf3523a211a 100644 (file)
 <h2 id="qunit-userAgent"></h2>
 <ol id="qunit-tests"></ol>
 <div id="qunit-fixture">
-       <div id="main"></div>
-       <div id="draggable1" style="background: green; width: 200px; height: 100px;">Relative</div>
-       <div id="draggable2" style="background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;"><span><em>Absolute</em></span></div>
-       <div id="droppable" style="background: green; width: 200px; height: 100px; position: absolute; top: 110px; left: 110px;"><span>Absolute</span></div>
+       <div id="main">
+               <div id="draggable1" style="background: green; width: 200px; height: 100px;">Relative</div>
+               <div id="draggable2" style="background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;"><span><em>Absolute</em></span></div>
+               <div id="droppable" style="background: green; width: 200px; height: 100px; position: absolute; top: 110px; left: 110px;"><span>Absolute</span></div>
+       </div>
        <div style="width: 1px; height: 1000px;"></div>
        <div style="position: absolute; width: 1px; height: 2000px;"></div>
 </div>
index ef551003dbeebc4ea5c13353e748d5c0d3cdb5af..27d53639f2cc389af25b96b6962b0d0893d24ecf 100644 (file)
@@ -43,7 +43,7 @@ test( "{ appendTo: 'parent' }, default", function() {
        equal( element.draggable( "option", "appendTo" ), "parent" );
 
        TestHelpers.draggable.move( element, 1, 1 );
-       equal( element.data( "last_dragged_parent" ), $( "#qunit-fixture" )[ 0 ] );
+       equal( element.data( "last_dragged_parent" ), $( "#main" )[ 0 ] );
 });
 
 test( "{ appendTo: Element }", function() {
@@ -91,12 +91,12 @@ test( "appendTo, default, switching after initialization", function() {
 
        // Move and make sure element was appended to fixture
        TestHelpers.draggable.move( element, 1, 1 );
-       equal( element.data( "last_dragged_parent" ), $( "#qunit-fixture" )[ 0 ] );
+       equal( element.data( "last_dragged_parent" ), $( "#main" )[ 0 ] );
 
        // Move and make sure element was appended to main
-       element.draggable( "option", "appendTo", $( "#main" ) );
+       element.draggable( "option", "appendTo", $( "#qunit-fixture" ) );
        TestHelpers.draggable.move( element, 2, 2 );
-       equal( element.data( "last_dragged_parent" ), $( "#main" )[ 0 ] );
+       equal( element.data( "last_dragged_parent" ), $( "#qunit-fixture" )[ 0 ] );
 });
 
 test( "{ axis: false }, default", function() {
index b365055568237fa9c9505d4a69af8b704184d7f0..00ff08d3e0c6d696bdaa36cc75af54b9f3bbf3dd 100644 (file)
@@ -12,7 +12,10 @@ TestHelpers.draggable = {
 
                $( handle ).simulate( "drag", {
                        dx: dx,
-                       dy: dy
+                       dy: dy,
+                       // moves is 1 here because simulate currently fire events synchronously
+                       // so we can't faithfully test things that rely on a scroll event (which is async)
+                       moves: 1
                });
                offsetAfter = el.offset();
 
@@ -43,9 +46,7 @@ TestHelpers.draggable = {
        },
        setScroll: function( what ) {
                if( what ) {
-                       // TODO: currently, the draggable interaction doesn't properly account for scrolled pages,
-                       // uncomment the line below to make the tests fail that should when the page is scrolled
-                       // $( document ).scrollTop( 100 ).scrollLeft( 100 );
+                       $( document ).scrollTop( 100 ).scrollLeft( 100 );
                } else {
                        $( "#main" ).scrollTop( 100 ).scrollLeft( 100 );
                }