2012-11-03 20:17:16 +00:00
|
|
|
TestHelpers.droppable = {
|
2013-02-24 22:43:44 +00:00
|
|
|
shouldDrop: function( source, target, why ) {
|
|
|
|
|
|
|
|
var dropped = this.detectDropped( source, target );
|
|
|
|
|
|
|
|
why = why ? "Dropped: " + why : "";
|
|
|
|
|
|
|
|
equal( dropped, true, + why );
|
|
|
|
|
2012-11-03 20:17:16 +00:00
|
|
|
},
|
2013-02-24 22:43:44 +00:00
|
|
|
shouldNotDrop: function( source, target, why ) {
|
|
|
|
|
|
|
|
var dropped = this.detectDropped( source, target );
|
|
|
|
|
|
|
|
why = why ? "Not Dropped: " + why : "";
|
|
|
|
|
|
|
|
equal( dropped, false, why );
|
|
|
|
},
|
|
|
|
detectDropped: function( source, target ) {
|
|
|
|
|
|
|
|
// TODO: Remove these lines after old tests upgraded
|
|
|
|
if ( !source || !target ){
|
|
|
|
ok(true, "missing test - untested code is broken code");
|
|
|
|
}
|
|
|
|
|
|
|
|
var targetOffset = target.offset(),
|
|
|
|
sourceOffset = source.offset(),
|
|
|
|
dropped = false;
|
|
|
|
|
|
|
|
$(target).on( "drop", function() {
|
|
|
|
dropped = true;
|
|
|
|
});
|
|
|
|
|
|
|
|
$(source).simulate( "drag", {
|
|
|
|
dx: targetOffset.left - sourceOffset.left,
|
|
|
|
dy: targetOffset.top - sourceOffset.top
|
|
|
|
});
|
|
|
|
|
|
|
|
return dropped;
|
|
|
|
|
2012-11-03 20:17:16 +00:00
|
|
|
}
|
|
|
|
};
|