From: Mike Sherov Date: Sat, 19 Oct 2013 19:47:13 +0000 (-0400) Subject: Draggable Tests: make sure offset tests are actually testing offsets X-Git-Tag: 1.11.0-beta.1~223 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=82edd58743bd8b601a8298caf620c104b92aba0d;p=jquery-ui.git Draggable Tests: make sure offset tests are actually testing offsets --- diff --git a/tests/unit/draggable/draggable.html b/tests/unit/draggable/draggable.html index 3d1d3326e..17f9745a6 100644 --- a/tests/unit/draggable/draggable.html +++ b/tests/unit/draggable/draggable.html @@ -46,10 +46,11 @@

    -
    -
    Relative
    -
    Absolute
    -
    Absolute
    +
    +
    Relative
    +
    Absolute
    +
    Absolute
    +
    diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index ef551003d..27d53639f 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -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() { diff --git a/tests/unit/draggable/draggable_test_helpers.js b/tests/unit/draggable/draggable_test_helpers.js index b36505556..00ff08d3e 100644 --- a/tests/unit/draggable/draggable_test_helpers.js +++ b/tests/unit/draggable/draggable_test_helpers.js @@ -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 ); }