Skip to content
Permalink
Browse files

Draggable Tests: clarify scroll helpers.

  • Loading branch information
mikesherov committed Oct 20, 2013
1 parent 82edd58 commit 0144b270c8addb5553db36e236782e747015b361
Showing with 58 additions and 66 deletions.
  1. +56 −56 tests/unit/draggable/draggable_options.js
  2. +2 −10 tests/unit/draggable/draggable_test_helpers.js
@@ -694,164 +694,164 @@ 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() {
expect( 3 );

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() {
expect( 3 );

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() {
expect( 3 );

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() {
expect( 3 );

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() {
expect( 3 );

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() {
expect( 3 );

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() {
expect( 3 );

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() {
expect( 3 );

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() {
@@ -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;

0 comments on commit 0144b27

Please sign in to comment.
You can’t perform that action at this time.