Skip to content

Commit a6271df

Browse files
committed
Tests: Add a tooltip test helper cleaning up leftover timers
1 parent 97720a5 commit a6271df

File tree

8 files changed

+63
-20
lines changed

8 files changed

+63
-20
lines changed

tests/unit/draggable/options.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ QUnit.test( "connectToSortable, dragging out of a sortable", function( assert )
302302
dx: dx,
303303
dy: dy
304304
} );
305+
306+
// Cleanup
307+
element.stop( true );
305308
} );
306309

307310
QUnit.test( "connectToSortable, dragging clone into sortable", function( assert ) {

tests/unit/sortable/options.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ QUnit.test( "#7415: Incorrect revert animation with axis: 'y'", function( assert
105105
var top = parseFloat( item.css( "top" ) );
106106
assert.equal( item.css( "left" ), expectedLeft, "left not animated" );
107107
assert.ok( top > 0 && top < 300, "top is animated" );
108+
109+
// Cleanup
110+
item.stop( true );
111+
108112
ready();
109113
}, 100 );
110114
} );

tests/unit/tooltip/core.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
define( [
22
"qunit",
33
"jquery",
4-
"lib/helper",
4+
"./helper",
55
"ui/widgets/tooltip"
6-
], function( QUnit, $, helper ) {
6+
], function( QUnit, $, testHelper ) {
77

8-
QUnit.module( "tooltip: core", { afterEach: helper.moduleAfterEach } );
8+
var beforeAfterEach = testHelper.beforeAfterEach;
9+
10+
QUnit.module( "tooltip: core", beforeAfterEach() );
911

1012
QUnit.test( "markup structure", function( assert ) {
1113
assert.expect( 7 );

tests/unit/tooltip/deprecated.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
define( [
22
"qunit",
33
"jquery",
4-
"lib/helper",
4+
"./helper",
55
"ui/widgets/tooltip"
6-
], function( QUnit, $, helper ) {
6+
], function( QUnit, $, testHelper ) {
77

8-
QUnit.module( "tooltip: (deprecated) options", { afterEach: helper.moduleAfterEach } );
8+
var beforeAfterEach = testHelper.beforeAfterEach;
9+
10+
QUnit.module( "tooltip: (deprecated) options", beforeAfterEach() );
911

1012
QUnit.test( "tooltipClass", function( assert ) {
1113
assert.expect( 1 );

tests/unit/tooltip/events.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
define( [
22
"qunit",
33
"jquery",
4-
"lib/helper",
4+
"./helper",
55
"ui/widgets/tooltip"
6-
], function( QUnit, $, helper ) {
6+
], function( QUnit, $, testHelper ) {
77

8-
QUnit.module( "tooltip: events", { afterEach: helper.moduleAfterEach } );
8+
var beforeAfterEach = testHelper.beforeAfterEach;
9+
10+
QUnit.module( "tooltip: events", beforeAfterEach() );
911

1012
QUnit.test( "programmatic triggers", function( assert ) {
1113
assert.expect( 4 );

tests/unit/tooltip/helper.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
define( [
2+
"qunit",
3+
"jquery",
4+
"lib/helper",
5+
"ui/widgets/tooltip"
6+
], function( QUnit, $, helper ) {
7+
8+
return $.extend( helper, {
9+
beforeAfterEach: function() {
10+
return {
11+
afterEach: function() {
12+
var index, timer,
13+
timers = jQuery.timers;
14+
15+
jQuery.fx.stop();
16+
var x = false;
17+
18+
for ( index = timers.length; index--; ) {
19+
x = true;
20+
timer = timers[ index ];
21+
timer.anim.stop();
22+
timers.splice( index, 1 );
23+
}
24+
25+
return helper.moduleAfterEach.apply( this, arguments );
26+
}
27+
};
28+
}
29+
} );
30+
31+
} );

tests/unit/tooltip/methods.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
define( [
22
"qunit",
33
"jquery",
4-
"lib/helper",
4+
"./helper",
55
"ui/widgets/tooltip"
6-
], function( QUnit, $, helper ) {
6+
], function( QUnit, $, testHelper ) {
77

8-
QUnit.module( "tooltip: methods", {
9-
afterEach: function() {
10-
jQuery.fx.stop();
11-
return helper.moduleAfterEach.apply( this, arguments );
12-
}
13-
} );
8+
var beforeAfterEach = testHelper.beforeAfterEach;
9+
10+
QUnit.module( "tooltip: methods", beforeAfterEach() );
1411

1512
QUnit.test( "destroy", function( assert ) {
1613
assert.expect( 3 );

tests/unit/tooltip/options.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
define( [
22
"qunit",
33
"jquery",
4-
"lib/helper",
4+
"./helper",
55
"ui/widgets/tooltip"
6-
], function( QUnit, $, helper ) {
6+
], function( QUnit, $, testHelper ) {
77

8-
QUnit.module( "tooltip: options", { afterEach: helper.moduleAfterEach } );
8+
var beforeAfterEach = testHelper.beforeAfterEach;
9+
10+
QUnit.module( "tooltip: options", beforeAfterEach() );
911

1012
QUnit.test( "disabled: true", function( assert ) {
1113
assert.expect( 1 );

0 commit comments

Comments
 (0)