mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Draggable Tests: Ensure scrolling and dragging tests assert correctly
This commit is contained in:
parent
aa425ab95d
commit
49c3fb7403
@ -344,7 +344,7 @@ test( "ui-draggable-handle managed correctly in nested draggables", function() {
|
||||
// http://bugs.jqueryui.com/ticket/7772
|
||||
// when css 'right' is set, element resizes on drag
|
||||
test( "setting right/bottom css shouldn't cause resize", function() {
|
||||
expect( 3 );
|
||||
expect( 4 );
|
||||
|
||||
var finalOffset,
|
||||
element = $( "#draggable3" ),
|
||||
@ -362,7 +362,8 @@ test( "setting right/bottom css shouldn't cause resize", function() {
|
||||
|
||||
closeEnough( element.width(), origWidth, 1, "element retains width" );
|
||||
closeEnough( element.height(), origHeight, 1, "element retains height" );
|
||||
deepEqual( finalOffset, origOffset, "element moves the correct distance" );
|
||||
closeEnough( finalOffset.top, origOffset.top, "element moves the correct vertical distance" );
|
||||
closeEnough( finalOffset.top, origOffset.top, "element moves the correct horizontal distance" );
|
||||
});
|
||||
|
||||
})( jQuery );
|
||||
|
@ -51,7 +51,7 @@ test( "destroy", function() {
|
||||
});
|
||||
|
||||
test( "enable", function() {
|
||||
expect( 7 );
|
||||
expect( 11 );
|
||||
|
||||
element.draggable({ disabled: true });
|
||||
TestHelpers.draggable.shouldNotDrag( element, ".draggable({ disabled: true })" );
|
||||
@ -74,7 +74,7 @@ test( "enable", function() {
|
||||
});
|
||||
|
||||
test( "disable", function() {
|
||||
expect( 10 );
|
||||
expect( 14 );
|
||||
|
||||
element = $( "#draggable2" ).draggable({ disabled: false });
|
||||
TestHelpers.draggable.shouldMove( element, ".draggable({ disabled: false })" );
|
||||
|
@ -156,7 +156,7 @@ test( "axis, default, switching after initialization", function() {
|
||||
});
|
||||
|
||||
test( "{ cancel: 'input,textarea,button,select,option' }, default", function() {
|
||||
expect( 2 );
|
||||
expect( 4 );
|
||||
|
||||
$( "<div id='draggable-option-cancel-default'><input type='text'></div>" ).appendTo( "#qunit-fixture" );
|
||||
|
||||
@ -171,7 +171,7 @@ test( "{ cancel: 'input,textarea,button,select,option' }, default", function() {
|
||||
});
|
||||
|
||||
test( "{ cancel: 'span' }", function() {
|
||||
expect( 2 );
|
||||
expect( 4 );
|
||||
|
||||
var element = $( "#draggable2" ).draggable();
|
||||
TestHelpers.draggable.shouldMove( element, "cancel: default, span dragged", "#draggable2 span" );
|
||||
@ -228,7 +228,7 @@ test( "{ cancel: Selectors }, matching parent selector", function() {
|
||||
*/
|
||||
|
||||
test( "cancelement, default, switching after initialization", function() {
|
||||
expect( 2 );
|
||||
expect( 6 );
|
||||
|
||||
$( "<div id='draggable-option-cancel-default'><input type='text'></div>" ).appendTo( "#qunit-fixture" );
|
||||
|
||||
@ -615,7 +615,7 @@ test( "cursorAt, switching after initialization", function() {
|
||||
});
|
||||
|
||||
test( "disabled", function() {
|
||||
expect( 4 );
|
||||
expect( 6 );
|
||||
|
||||
var element = $( "#draggable1" ).draggable();
|
||||
|
||||
@ -660,7 +660,7 @@ test( "grid, switching after initialization", function() {
|
||||
});
|
||||
|
||||
test( "{ handle: 'span' }", function() {
|
||||
expect( 4 );
|
||||
expect( 6 );
|
||||
|
||||
var element = $( "#draggable2" ).draggable({ handle: "span" });
|
||||
|
||||
@ -670,7 +670,7 @@ test( "{ handle: 'span' }", function() {
|
||||
});
|
||||
|
||||
test( "handle, default, switching after initialization", function() {
|
||||
expect( 10 );
|
||||
expect( 12 );
|
||||
|
||||
var element = $( "#draggable2" ).draggable();
|
||||
|
||||
|
@ -63,14 +63,28 @@ TestHelpers.draggable = {
|
||||
},
|
||||
shouldNotDrag: function( el, msg, handle ) {
|
||||
handle = handle || el;
|
||||
$( el ).bind( "dragstop", function() {
|
||||
|
||||
var newOffset,
|
||||
element = $( el ),
|
||||
beginOffset = element.offset();
|
||||
|
||||
element.bind( "dragstop", function() {
|
||||
ok( false, "should not drag " + msg );
|
||||
});
|
||||
|
||||
$( handle ).simulate( "drag", {
|
||||
dx: 100,
|
||||
dy: 100
|
||||
});
|
||||
$( el ).unbind( "dragstop" );
|
||||
|
||||
newOffset = element.offset();
|
||||
|
||||
// Also assert that draggable did not move, to ensure it isn't just
|
||||
// that drag did not fire and draggable still somehow moved
|
||||
equal( newOffset.left, beginOffset.left, "Offset left should not be different" );
|
||||
equal( newOffset.top, beginOffset.top, "Offset top should not be different" );
|
||||
|
||||
element.unbind( "dragstop" );
|
||||
},
|
||||
setScrollable: function( what, isScrollable ) {
|
||||
var overflow = isScrollable ? "scroll" : "hidden";
|
||||
|
@ -205,9 +205,11 @@ TestHelpers.onFocus= function( element, onFocus ) {
|
||||
};
|
||||
|
||||
TestHelpers.forceScrollableWindow = function( appendTo ) {
|
||||
// The main testable area is 10000x10000 so to enforce scrolling,
|
||||
// this DIV must be greater than 10000 to work
|
||||
return $( "<div>" ).css({
|
||||
height: "10000px",
|
||||
width: "10000px"
|
||||
height: "11000px",
|
||||
width: "11000px"
|
||||
}).appendTo( appendTo || "#qunit-fixture" );
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user