jquery-ui/tests/unit/droppable/events.js
Michał Gołębiowski-Owczarek e7a10c70ae
Tests: Ensure no timers are running at the end of each test (#1920)
This helps fix issues that make tooltip tests sometimes fail when run against
jQuery 3.2 or newer due to timing differences.

Details:
* Add the `moduleAfterEach` function ensuring no timers are running.
* Attach this function via `common.testWidget`.
* Attach this function to most test suites.
* Add a tooltip test helper cleaning up leftover timers.
* Rename legacy `setup`/`teardown` hooks to `beforeEach`/`afterEach`.

Closes gh-1920
2020-05-16 09:16:24 +02:00

67 lines
1.6 KiB
JavaScript

define( [
"qunit",
"jquery",
"lib/helper",
"ui/widgets/droppable"
], function( QUnit, $, helper ) {
QUnit.module( "droppable: events", { afterEach: helper.moduleAfterEach } );
QUnit.test( "droppable destruction/recreation on drop event", function( assert ) {
assert.expect( 1 );
var config = {
activeClass: "active",
drop: function() {
var element = $( this ),
newDroppable = $( "<div>" )
.css( { width: 100, height: 100 } )
.text( "Droppable" );
element.after( newDroppable );
element.remove();
newDroppable.droppable( config );
}
},
draggable = $( "#draggable1" ).draggable(),
droppable1 = $( "#droppable1" ).droppable( config ),
droppable2 = $( "#droppable2" ).droppable( config ),
droppableOffset = droppable1.offset(),
draggableOffset = draggable.offset(),
dx = droppableOffset.left - draggableOffset.left,
dy = droppableOffset.top - draggableOffset.top;
draggable.simulate( "drag", {
dx: dx,
dy: dy
} );
assert.lacksClasses( droppable2, "active", "subsequent droppable no longer active" );
} );
// Todo: comment the following in when ready to actually test
/*
Test("activate", function() {
ok(false, 'missing test - untested code is broken code');
});
test("deactivate", function() {
ok(false, 'missing test - untested code is broken code');
});
test("over", function() {
ok(false, 'missing test - untested code is broken code');
});
test("out", function() {
ok(false, 'missing test - untested code is broken code');
});
test("drop", function() {
ok(false, 'missing test - untested code is broken code');
});
*/
} );