Skip to content

Commit 82edd58

Browse files
committed
Draggable Tests: make sure offset tests are actually testing offsets
1 parent 67fd40e commit 82edd58

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

tests/unit/draggable/draggable.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ <h2 id="qunit-banner"></h2>
4646
<h2 id="qunit-userAgent"></h2>
4747
<ol id="qunit-tests"></ol>
4848
<div id="qunit-fixture">
49-
<div id="main"></div>
50-
<div id="draggable1" style="background: green; width: 200px; height: 100px;">Relative</div>
51-
<div id="draggable2" style="background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;"><span><em>Absolute</em></span></div>
52-
<div id="droppable" style="background: green; width: 200px; height: 100px; position: absolute; top: 110px; left: 110px;"><span>Absolute</span></div>
49+
<div id="main">
50+
<div id="draggable1" style="background: green; width: 200px; height: 100px;">Relative</div>
51+
<div id="draggable2" style="background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;"><span><em>Absolute</em></span></div>
52+
<div id="droppable" style="background: green; width: 200px; height: 100px; position: absolute; top: 110px; left: 110px;"><span>Absolute</span></div>
53+
</div>
5354
<div style="width: 1px; height: 1000px;"></div>
5455
<div style="position: absolute; width: 1px; height: 2000px;"></div>
5556
</div>

tests/unit/draggable/draggable_options.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ test( "{ appendTo: 'parent' }, default", function() {
4343
equal( element.draggable( "option", "appendTo" ), "parent" );
4444

4545
TestHelpers.draggable.move( element, 1, 1 );
46-
equal( element.data( "last_dragged_parent" ), $( "#qunit-fixture" )[ 0 ] );
46+
equal( element.data( "last_dragged_parent" ), $( "#main" )[ 0 ] );
4747
});
4848

4949
test( "{ appendTo: Element }", function() {
@@ -91,12 +91,12 @@ test( "appendTo, default, switching after initialization", function() {
9191

9292
// Move and make sure element was appended to fixture
9393
TestHelpers.draggable.move( element, 1, 1 );
94-
equal( element.data( "last_dragged_parent" ), $( "#qunit-fixture" )[ 0 ] );
94+
equal( element.data( "last_dragged_parent" ), $( "#main" )[ 0 ] );
9595

9696
// Move and make sure element was appended to main
97-
element.draggable( "option", "appendTo", $( "#main" ) );
97+
element.draggable( "option", "appendTo", $( "#qunit-fixture" ) );
9898
TestHelpers.draggable.move( element, 2, 2 );
99-
equal( element.data( "last_dragged_parent" ), $( "#main" )[ 0 ] );
99+
equal( element.data( "last_dragged_parent" ), $( "#qunit-fixture" )[ 0 ] );
100100
});
101101

102102
test( "{ axis: false }, default", function() {

tests/unit/draggable/draggable_test_helpers.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ TestHelpers.draggable = {
1212

1313
$( handle ).simulate( "drag", {
1414
dx: dx,
15-
dy: dy
15+
dy: dy,
16+
// moves is 1 here because simulate currently fire events synchronously
17+
// so we can't faithfully test things that rely on a scroll event (which is async)
18+
moves: 1
1619
});
1720
offsetAfter = el.offset();
1821

@@ -43,9 +46,7 @@ TestHelpers.draggable = {
4346
},
4447
setScroll: function( what ) {
4548
if( what ) {
46-
// TODO: currently, the draggable interaction doesn't properly account for scrolled pages,
47-
// uncomment the line below to make the tests fail that should when the page is scrolled
48-
// $( document ).scrollTop( 100 ).scrollLeft( 100 );
49+
$( document ).scrollTop( 100 ).scrollLeft( 100 );
4950
} else {
5051
$( "#main" ).scrollTop( 100 ).scrollLeft( 100 );
5152
}

0 commit comments

Comments
 (0)