2015-04-06 18:38:11 +00:00
|
|
|
define( [
|
2016-04-06 13:13:06 +00:00
|
|
|
"qunit",
|
2015-04-06 18:38:11 +00:00
|
|
|
"jquery",
|
|
|
|
"lib/helper",
|
2015-07-15 02:05:54 +00:00
|
|
|
"ui/widgets/selectable"
|
2016-04-06 13:13:06 +00:00
|
|
|
], function( QUnit, $, testHelpers ) {
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2020-05-16 07:16:24 +00:00
|
|
|
QUnit.module( "selectable: events", { afterEach: testHelpers.moduleAfterEach } );
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2016-04-06 13:13:06 +00:00
|
|
|
QUnit.test( "start", function( assert ) {
|
|
|
|
assert.expect( 2 );
|
2015-08-24 12:58:20 +00:00
|
|
|
var el = $( "#selectable1" );
|
|
|
|
el.selectable( {
|
2012-10-23 14:36:42 +00:00
|
|
|
start: function() {
|
2016-04-06 13:13:06 +00:00
|
|
|
assert.ok( true, "drag fired start callback" );
|
|
|
|
assert.equal( this, el[ 0 ], "context of callback" );
|
2009-02-04 04:53:09 +00:00
|
|
|
}
|
2015-08-24 12:58:20 +00:00
|
|
|
} );
|
2012-12-09 02:27:37 +00:00
|
|
|
el.simulate( "drag", {
|
|
|
|
dx: 20,
|
|
|
|
dy: 20
|
2015-08-24 12:58:20 +00:00
|
|
|
} );
|
|
|
|
} );
|
2009-02-04 04:53:09 +00:00
|
|
|
|
2016-04-06 13:13:06 +00:00
|
|
|
QUnit.test( "stop", function( assert ) {
|
|
|
|
assert.expect( 2 );
|
2015-08-24 12:58:20 +00:00
|
|
|
var el = $( "#selectable1" );
|
|
|
|
el.selectable( {
|
2012-10-23 14:36:42 +00:00
|
|
|
start: function() {
|
2016-04-06 13:13:06 +00:00
|
|
|
assert.ok( true, "drag fired stop callback" );
|
|
|
|
assert.equal( this, el[ 0 ], "context of callback" );
|
2009-02-04 04:53:09 +00:00
|
|
|
}
|
2015-08-24 12:58:20 +00:00
|
|
|
} );
|
2012-12-09 02:27:37 +00:00
|
|
|
el.simulate( "drag", {
|
|
|
|
dx: 20,
|
|
|
|
dy: 20
|
2015-08-24 12:58:20 +00:00
|
|
|
} );
|
|
|
|
} );
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2016-04-06 13:13:06 +00:00
|
|
|
QUnit.test( "mousedown: initial position of helper", function( assert ) {
|
|
|
|
assert.expect( 2 );
|
2012-12-29 03:17:50 +00:00
|
|
|
|
2013-03-31 15:49:54 +00:00
|
|
|
var helperOffset,
|
|
|
|
element = $( "#selectable1" ).selectable(),
|
2015-04-06 18:38:11 +00:00
|
|
|
contentToForceScroll = testHelpers.forceScrollableWindow( "body" );
|
2012-12-29 03:17:50 +00:00
|
|
|
|
2013-03-31 15:49:54 +00:00
|
|
|
$( window ).scrollTop( 100 ).scrollLeft( 100 );
|
2012-12-29 03:17:50 +00:00
|
|
|
|
|
|
|
element.simulate( "mousedown", {
|
|
|
|
clientX: 10,
|
|
|
|
clientY: 10
|
2015-08-24 12:58:20 +00:00
|
|
|
} );
|
2012-12-29 03:17:50 +00:00
|
|
|
|
2013-03-31 15:49:54 +00:00
|
|
|
helperOffset = $( ".ui-selectable-helper" ).offset();
|
2016-04-06 13:13:06 +00:00
|
|
|
assert.ok( helperOffset.top, 110, "Scroll top should be accounted for." );
|
|
|
|
assert.ok( helperOffset.left, 110, "Scroll left should be accounted for." );
|
2012-12-29 03:17:50 +00:00
|
|
|
|
|
|
|
// Cleanup
|
2013-03-31 15:49:54 +00:00
|
|
|
element.simulate( "mouseup" );
|
2012-12-29 03:17:50 +00:00
|
|
|
contentToForceScroll.remove();
|
|
|
|
$( window ).scrollTop( 0 ).scrollLeft( 0 );
|
2015-08-24 12:58:20 +00:00
|
|
|
} );
|
2012-12-29 03:17:50 +00:00
|
|
|
|
2015-04-06 18:38:11 +00:00
|
|
|
} );
|