From f183af44a8ce5f67bfb33c3d0ea6076519c58065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Go=C5=82e=CC=A8biowski-Owczarek?= Date: Wed, 13 May 2020 22:34:59 +0200 Subject: [PATCH 1/4] Tests: Ensure no timers are running at the end of each test This helps fix issues that make tooltip tests sometimes fail when run against jQuery 3.2 or newer due to timing differences. This commit adds a function to be attached at `afterEach` & attaches it to `common.testWidget`. --- tests/lib/common.js | 7 ++++--- tests/lib/helper.js | 25 ++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/tests/lib/common.js b/tests/lib/common.js index 7d3b3db2ab9..dbb9eea8bab 100644 --- a/tests/lib/common.js +++ b/tests/lib/common.js @@ -1,7 +1,8 @@ define( [ "qunit", - "jquery" ], -function( QUnit, $ ) { + "jquery", + "lib/helper" +], function( QUnit, $, helper ) { var exports = {}; @@ -66,7 +67,7 @@ function testBasicUsage( widget ) { } exports.testWidget = function( widget, settings ) { - QUnit.module( widget + ": common widget" ); + QUnit.module( widget + ": common widget", { afterEach: helper.moduleAfterEach } ); exports.testJshint( "/widgets/" + widget ); testWidgetDefaults( widget, settings.defaults ); diff --git a/tests/lib/helper.js b/tests/lib/helper.js index 400d854897c..2315c5e19d4 100644 --- a/tests/lib/helper.js +++ b/tests/lib/helper.js @@ -2,7 +2,12 @@ define( [ "jquery" ], function( $ ) { -var exports = {}; +var exports = {}, + + // Store the old count so that we only assert on tests that have actually leaked, + // instead of asserting every time a test has leaked sometime in the past + oldActive = 0, + splice = [].splice; exports.forceScrollableWindow = function( appendTo ) { @@ -28,6 +33,24 @@ exports.onFocus = function( element, onFocus ) { element.on( "focus", fn )[ 0 ].focus(); }; +/** + * Ensures that tests have cleaned up properly after themselves. Should be passed as the + * afterEach function on all modules' lifecycle object. + */ +exports.moduleAfterEach = function( assert ) { + + // Check for (and clean up, if possible) incomplete animations/requests/etc. + if ( jQuery.timers && jQuery.timers.length !== 0 ) { + assert.equal( jQuery.timers.length, 0, "No timers are still running" ); + splice.call( jQuery.timers, 0, jQuery.timers.length ); + jQuery.fx.stop(); + } + if ( jQuery.active !== undefined && jQuery.active !== oldActive ) { + assert.equal( jQuery.active, oldActive, "No AJAX requests are still active" ); + oldActive = jQuery.active; + } +}; + return exports; } ); From dd25699969e24a782a71f029e55d66b25521a446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Go=C5=82e=CC=A8biowski-Owczarek?= Date: Wed, 13 May 2020 22:36:33 +0200 Subject: [PATCH 2/4] Tests: Rename legacy setup/teardown hooks to beforeEach/afterEach --- tests/unit/controlgroup/core.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/controlgroup/core.js b/tests/unit/controlgroup/core.js index 789eefc90ab..ec13c43e4fe 100644 --- a/tests/unit/controlgroup/core.js +++ b/tests/unit/controlgroup/core.js @@ -161,12 +161,12 @@ QUnit.test( "Single controlgroup button - vertical", function( assert ) { } ); QUnit.module( "Controlgroup: Non-empty class key", { - setup: function() { + beforeEach: function() { this.classKey = $.ui.selectmenu.prototype.options.classes[ "ui-selectmenu-button-closed" ]; $.ui.selectmenu.prototype.options.classes[ "ui-selectmenu-button-closed" ] = "something-custom"; }, - teardown: function() { + afterEach: function() { $.ui.selectmenu.prototype.options.classes[ "ui-selectmenu-button-closed" ] = this.classKey; } } ); From 97720a5926c6cab61c07aedc7eea3eb991594ed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Go=C5=82e=CC=A8biowski-Owczarek?= Date: Wed, 13 May 2020 22:39:29 +0200 Subject: [PATCH 3/4] Tests: Ensure no timers are running at the end of each test This helps fix issues that make tooltip tests sometimes fail when run against jQuery 3.2 or newer due to timing differences. This commit attaches the `moduleAfterEach` function with timer checks to most test suites. --- tests/unit/accordion/core.js | 4 ++-- tests/unit/accordion/events.js | 4 ++-- tests/unit/accordion/helper.js | 7 ++++--- tests/unit/accordion/methods.js | 4 ++-- tests/unit/accordion/options.js | 4 ++-- tests/unit/autocomplete/core.js | 5 +++-- tests/unit/autocomplete/events.js | 5 +++-- tests/unit/autocomplete/methods.js | 5 +++-- tests/unit/autocomplete/options.js | 5 +++-- tests/unit/button/core.js | 5 +++-- tests/unit/button/deprecated.js | 9 +++++---- tests/unit/button/events.js | 5 +++-- tests/unit/button/methods.js | 5 +++-- tests/unit/button/options.js | 5 +++-- tests/unit/checkboxradio/core.js | 5 +++-- tests/unit/checkboxradio/events.js | 5 +++-- tests/unit/checkboxradio/methods.js | 5 +++-- tests/unit/checkboxradio/options.js | 5 +++-- tests/unit/controlgroup/core.js | 5 +++-- tests/unit/controlgroup/methods.js | 5 +++-- tests/unit/controlgroup/options.js | 5 +++-- tests/unit/core/core.js | 5 +++-- tests/unit/core/selector.js | 5 +++-- tests/unit/datepicker/core.js | 6 ++++-- tests/unit/datepicker/events.js | 4 +++- tests/unit/datepicker/helper.js | 6 ++++++ tests/unit/datepicker/methods.js | 4 +++- tests/unit/datepicker/options.js | 4 +++- tests/unit/dialog/core.js | 7 ++++--- tests/unit/dialog/deprecated.js | 5 +++-- tests/unit/dialog/events.js | 2 +- tests/unit/dialog/methods.js | 4 +++- tests/unit/dialog/options.js | 5 +++-- tests/unit/draggable/core.js | 5 +++-- tests/unit/draggable/events.js | 4 +++- tests/unit/draggable/methods.js | 4 +++- tests/unit/draggable/options.js | 5 +++-- tests/unit/droppable/core.js | 5 +++-- tests/unit/droppable/events.js | 5 +++-- tests/unit/droppable/methods.js | 5 +++-- tests/unit/droppable/options.js | 5 +++-- tests/unit/effects/core.js | 9 +++++---- tests/unit/effects/scale.js | 5 +++-- tests/unit/form-reset-mixin/core.js | 4 +++- tests/unit/menu/core.js | 5 +++-- tests/unit/menu/events.js | 6 ++++-- tests/unit/menu/methods.js | 6 ++++-- tests/unit/menu/options.js | 6 ++++-- tests/unit/position/core.js | 6 ++++-- tests/unit/progressbar/core.js | 5 +++-- tests/unit/progressbar/events.js | 5 +++-- tests/unit/progressbar/methods.js | 5 +++-- tests/unit/progressbar/options.js | 5 +++-- tests/unit/resizable/core.js | 5 +++-- tests/unit/resizable/events.js | 5 +++-- tests/unit/resizable/methods.js | 5 +++-- tests/unit/resizable/options.js | 5 +++-- tests/unit/selectable/events.js | 2 +- tests/unit/selectable/methods.js | 5 +++-- tests/unit/selectable/options.js | 5 +++-- tests/unit/selectmenu/core.js | 5 +++-- tests/unit/selectmenu/events.js | 6 ++++-- tests/unit/selectmenu/methods.js | 5 +++-- tests/unit/selectmenu/options.js | 5 +++-- tests/unit/slider/core.js | 5 +++-- tests/unit/slider/events.js | 5 +++-- tests/unit/slider/methods.js | 5 +++-- tests/unit/slider/options.js | 5 +++-- tests/unit/sortable/core.js | 5 +++-- tests/unit/sortable/events.js | 5 +++-- tests/unit/sortable/methods.js | 5 +++-- tests/unit/sortable/options.js | 5 +++-- tests/unit/spinner/core.js | 5 +++-- tests/unit/spinner/deprecated.js | 4 +++- tests/unit/spinner/events.js | 5 +++-- tests/unit/spinner/methods.js | 5 +++-- tests/unit/spinner/options.js | 5 +++-- tests/unit/tabs/core.js | 5 +++-- tests/unit/tabs/events.js | 5 +++-- tests/unit/tabs/methods.js | 5 +++-- tests/unit/tabs/options.js | 5 +++-- tests/unit/tooltip/core.js | 5 +++-- tests/unit/tooltip/deprecated.js | 5 +++-- tests/unit/tooltip/events.js | 5 +++-- tests/unit/tooltip/methods.js | 10 ++++++++-- tests/unit/tooltip/options.js | 5 +++-- tests/unit/widget/animation.js | 4 +++- tests/unit/widget/classes.js | 4 +++- tests/unit/widget/core.js | 4 +++- 89 files changed, 279 insertions(+), 169 deletions(-) diff --git a/tests/unit/accordion/core.js b/tests/unit/accordion/core.js index 0b334c00cde..2829d312373 100644 --- a/tests/unit/accordion/core.js +++ b/tests/unit/accordion/core.js @@ -5,10 +5,10 @@ define( [ "ui/widgets/accordion" ], function( QUnit, $, testHelper ) { -var setupTeardown = testHelper.setupTeardown, +var beforeAfterEach = testHelper.beforeAfterEach, state = testHelper.state; -QUnit.module( "accordion: core", setupTeardown() ); +QUnit.module( "accordion: core", beforeAfterEach() ); $.each( { div: "#list1", ul: "#navigation", dl: "#accordion-dl" }, function( type, selector ) { QUnit.test( "markup structure: " + type, function( assert ) { diff --git a/tests/unit/accordion/events.js b/tests/unit/accordion/events.js index b9af7ce0649..5b852513229 100644 --- a/tests/unit/accordion/events.js +++ b/tests/unit/accordion/events.js @@ -5,10 +5,10 @@ define( [ "ui/widgets/accordion" ], function( QUnit, $, testHelper ) { -var setupTeardown = testHelper.setupTeardown, +var beforeAfterEach = testHelper.beforeAfterEach, state = testHelper.state; -QUnit.module( "accordion: events", setupTeardown() ); +QUnit.module( "accordion: events", beforeAfterEach() ); QUnit.test( "create", function( assert ) { assert.expect( 10 ); diff --git a/tests/unit/accordion/helper.js b/tests/unit/accordion/helper.js index 80bfc1854cc..3211765af06 100644 --- a/tests/unit/accordion/helper.js +++ b/tests/unit/accordion/helper.js @@ -12,14 +12,15 @@ return $.extend( helper, { } ); }, - setupTeardown: function() { + beforeAfterEach: function() { var animate = $.ui.accordion.prototype.options.animate; return { - setup: function() { + beforeEach: function() { $.ui.accordion.prototype.options.animate = false; }, - teardown: function() { + afterEach: function() { $.ui.accordion.prototype.options.animate = animate; + return helper.moduleAfterEach.apply( this, arguments ); } }; }, diff --git a/tests/unit/accordion/methods.js b/tests/unit/accordion/methods.js index 1b11e91ee6b..62223578502 100644 --- a/tests/unit/accordion/methods.js +++ b/tests/unit/accordion/methods.js @@ -6,10 +6,10 @@ define( [ ], function( QUnit, $, testHelper ) { var equalHeight = testHelper.equalHeight, - setupTeardown = testHelper.setupTeardown, + beforeAfterEach = testHelper.beforeAfterEach, state = testHelper.state; -QUnit.module( "accordion: methods", setupTeardown() ); +QUnit.module( "accordion: methods", beforeAfterEach() ); QUnit.test( "destroy", function( assert ) { assert.expect( 1 ); diff --git a/tests/unit/accordion/options.js b/tests/unit/accordion/options.js index 0fcaf5b7864..ae53e5c45cf 100644 --- a/tests/unit/accordion/options.js +++ b/tests/unit/accordion/options.js @@ -6,10 +6,10 @@ define( [ ], function( QUnit, $, testHelper ) { var equalHeight = testHelper.equalHeight, - setupTeardown = testHelper.setupTeardown, + beforeAfterEach = testHelper.beforeAfterEach, state = testHelper.state; -QUnit.module( "accordion: options", setupTeardown() ); +QUnit.module( "accordion: options", beforeAfterEach() ); QUnit.test( "{ active: default }", function( assert ) { assert.expect( 2 ); diff --git a/tests/unit/autocomplete/core.js b/tests/unit/autocomplete/core.js index 33ccb2f34da..8768ec2af58 100644 --- a/tests/unit/autocomplete/core.js +++ b/tests/unit/autocomplete/core.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/autocomplete" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "autocomplete: core" ); +QUnit.module( "autocomplete: core", { afterEach: helper.moduleAfterEach } ); QUnit.test( "markup structure", function( assert ) { assert.expect( 2 ); diff --git a/tests/unit/autocomplete/events.js b/tests/unit/autocomplete/events.js index f02d36dd740..801c2d935b2 100644 --- a/tests/unit/autocomplete/events.js +++ b/tests/unit/autocomplete/events.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/autocomplete" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "autocomplete: events" ); +QUnit.module( "autocomplete: events", { afterEach: helper.moduleAfterEach } ); var data = [ "Clojure", "COBOL", "ColdFusion", "Java", "JavaScript", "Scala", "Scheme" ]; diff --git a/tests/unit/autocomplete/methods.js b/tests/unit/autocomplete/methods.js index 7aa3058b3cf..597c9c2ada6 100644 --- a/tests/unit/autocomplete/methods.js +++ b/tests/unit/autocomplete/methods.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/autocomplete" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "autocomplete: methods" ); +QUnit.module( "autocomplete: methods", { afterEach: helper.moduleAfterEach } ); QUnit.test( "destroy", function( assert ) { assert.expect( 1 ); diff --git a/tests/unit/autocomplete/options.js b/tests/unit/autocomplete/options.js index c3f445db1f4..c4de8d5d336 100644 --- a/tests/unit/autocomplete/options.js +++ b/tests/unit/autocomplete/options.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/autocomplete" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "autocomplete: options" ); +QUnit.module( "autocomplete: options", { afterEach: helper.moduleAfterEach } ); var data = [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl" ]; diff --git a/tests/unit/button/core.js b/tests/unit/button/core.js index 98219c66cde..d5d19f9536a 100644 --- a/tests/unit/button/core.js +++ b/tests/unit/button/core.js @@ -1,11 +1,12 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/safe-active-element", "ui/widgets/button" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "Button: core" ); +QUnit.module( "Button: core", { afterEach: helper.moduleAfterEach } ); QUnit.test( "Disabled button loses focus", function( assert ) { var ready = assert.async(); diff --git a/tests/unit/button/deprecated.js b/tests/unit/button/deprecated.js index 86fca797e94..6866f73713e 100644 --- a/tests/unit/button/deprecated.js +++ b/tests/unit/button/deprecated.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/button" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "Button (deprecated): core" ); +QUnit.module( "Button (deprecated): core", { afterEach: helper.moduleAfterEach } ); QUnit.test( "Calling button on a checkbox input calls checkboxradio widget", function( assert ) { var checkbox = $( "#checkbox01" ); @@ -27,7 +28,7 @@ QUnit.test( "Calling buttonset calls controlgroup", function( assert ) { assert.ok( controlgroup.is( ":ui-controlgroup" ), "Calling buttonset creates controlgroup instance" ); } ); -QUnit.module( "Button (deprecated): methods" ); +QUnit.module( "Button (deprecated): methods", { afterEach: helper.moduleAfterEach } ); QUnit.test( "destroy", function( assert ) { assert.expect( 1 ); @@ -59,7 +60,7 @@ QUnit.test( "refresh: Ensure disabled state is preserved correctly.", function( } ); -QUnit.module( "button (deprecated): options" ); +QUnit.module( "button (deprecated): options", { afterEach: helper.moduleAfterEach } ); QUnit.test( "Setting items option on buttonset sets the button properties on the items option", function( assert ) { assert.expect( 2 ); diff --git a/tests/unit/button/events.js b/tests/unit/button/events.js index e8b5e01d6ba..57740736145 100644 --- a/tests/unit/button/events.js +++ b/tests/unit/button/events.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/button" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "Button: events" ); +QUnit.module( "Button: events", { afterEach: helper.moduleAfterEach } ); QUnit.test( "Anchor recieves click event when spacebar is pressed", function( assert ) { var ready = assert.async(); diff --git a/tests/unit/button/methods.js b/tests/unit/button/methods.js index 823acee3456..80ce27b398a 100644 --- a/tests/unit/button/methods.js +++ b/tests/unit/button/methods.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/button" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "Button: methods" ); +QUnit.module( "Button: methods", { afterEach: helper.moduleAfterEach } ); QUnit.test( "destroy", function( assert ) { assert.expect( 1 ); diff --git a/tests/unit/button/options.js b/tests/unit/button/options.js index 7d6547ff1f4..8a9acd60b90 100644 --- a/tests/unit/button/options.js +++ b/tests/unit/button/options.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/button" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "button: options" ); +QUnit.module( "button: options", { afterEach: helper.moduleAfterEach } ); QUnit.test( "disabled, explicit value", function( assert ) { assert.expect( 8 ); diff --git a/tests/unit/checkboxradio/core.js b/tests/unit/checkboxradio/core.js index 39d8c68319d..e1211773df9 100644 --- a/tests/unit/checkboxradio/core.js +++ b/tests/unit/checkboxradio/core.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/checkboxradio" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "Checkboxradio: core" ); +QUnit.module( "Checkboxradio: core", { afterEach: helper.moduleAfterEach } ); QUnit.test( "Checkbox - Initial class structure", function( assert ) { assert.expect( 2 ); diff --git a/tests/unit/checkboxradio/events.js b/tests/unit/checkboxradio/events.js index 96580c79127..0760a4387f8 100644 --- a/tests/unit/checkboxradio/events.js +++ b/tests/unit/checkboxradio/events.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/checkboxradio" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "Checkboxradio: events" ); +QUnit.module( "Checkboxradio: events", { afterEach: helper.moduleAfterEach } ); QUnit.test( "Resetting a checkbox's form should refresh the visual state of the checkbox", diff --git a/tests/unit/checkboxradio/methods.js b/tests/unit/checkboxradio/methods.js index 673c93766ad..bfb30dbced8 100644 --- a/tests/unit/checkboxradio/methods.js +++ b/tests/unit/checkboxradio/methods.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/checkboxradio" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "Checkboxradio: methods" ); +QUnit.module( "Checkboxradio: methods", { afterEach: helper.moduleAfterEach } ); $.each( [ "checkbox", "radio" ], function( index, value ) { QUnit.test( value + ": refresh", function( assert ) { diff --git a/tests/unit/checkboxradio/options.js b/tests/unit/checkboxradio/options.js index c0fc333c3a8..256381da677 100644 --- a/tests/unit/checkboxradio/options.js +++ b/tests/unit/checkboxradio/options.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/checkboxradio" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "Checkboxradio: options" ); +QUnit.module( "Checkboxradio: options", { afterEach: helper.moduleAfterEach } ); function assertDisabled( checkbox, assert ) { assert.hasClasses( checkbox.checkboxradio( "widget" ), "ui-state-disabled", diff --git a/tests/unit/controlgroup/core.js b/tests/unit/controlgroup/core.js index ec13c43e4fe..baccb3b1689 100644 --- a/tests/unit/controlgroup/core.js +++ b/tests/unit/controlgroup/core.js @@ -1,14 +1,15 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/controlgroup", "ui/widgets/checkboxradio", "ui/widgets/selectmenu", "ui/widgets/button", "ui/widgets/spinner" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "Controlgroup: Core" ); +QUnit.module( "Controlgroup: Core", { afterEach: helper.moduleAfterEach } ); QUnit.test( "selectmenu: open/close corners", function( assert ) { assert.expect( 12 ); diff --git a/tests/unit/controlgroup/methods.js b/tests/unit/controlgroup/methods.js index 09271d39f28..8f1f5894775 100644 --- a/tests/unit/controlgroup/methods.js +++ b/tests/unit/controlgroup/methods.js @@ -1,14 +1,15 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/controlgroup", "ui/widgets/checkboxradio", "ui/widgets/selectmenu", "ui/widgets/button", "ui/widgets/spinner" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "Controlgroup: methods" ); +QUnit.module( "Controlgroup: methods", { afterEach: helper.moduleAfterEach } ); QUnit.test( "destroy", function( assert ) { assert.expect( 1 ); diff --git a/tests/unit/controlgroup/options.js b/tests/unit/controlgroup/options.js index db9a29a2d35..4fc87067500 100644 --- a/tests/unit/controlgroup/options.js +++ b/tests/unit/controlgroup/options.js @@ -1,14 +1,15 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/controlgroup", "ui/widgets/checkboxradio", "ui/widgets/selectmenu", "ui/widgets/button", "ui/widgets/spinner" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "Controlgroup: options" ); +QUnit.module( "Controlgroup: options", { afterEach: helper.moduleAfterEach } ); QUnit.test( "disabled", function( assert ) { assert.expect( 4 ); diff --git a/tests/unit/core/core.js b/tests/unit/core/core.js index acfc291ff27..94c1261236f 100644 --- a/tests/unit/core/core.js +++ b/tests/unit/core/core.js @@ -2,12 +2,13 @@ define( [ "qunit", "jquery", "lib/common", + "lib/helper", "ui/form", "ui/labels", "ui/unique-id" -], function( QUnit, $, common ) { +], function( QUnit, $, common, helper ) { -QUnit.module( "core - jQuery extensions" ); +QUnit.module( "core - jQuery extensions", { afterEach: helper.moduleAfterEach } ); common.testJshint( "core" ); diff --git a/tests/unit/core/selector.js b/tests/unit/core/selector.js index 29b8b129680..f8b9f20c360 100644 --- a/tests/unit/core/selector.js +++ b/tests/unit/core/selector.js @@ -1,13 +1,14 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/data", "ui/escape-selector", "ui/focusable", "ui/tabbable" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "core - selectors" ); +QUnit.module( "core - selectors", { afterEach: helper.moduleAfterEach } ); QUnit.assert.isFocusable = function( selector, msg ) { this.push( $( selector ).is( ":focusable" ), null, null, diff --git a/tests/unit/datepicker/core.js b/tests/unit/datepicker/core.js index 2cc89cd21b9..2c4b7740263 100644 --- a/tests/unit/datepicker/core.js +++ b/tests/unit/datepicker/core.js @@ -2,15 +2,17 @@ define( [ "qunit", "jquery", "lib/common", + "lib/helper", "./helper", "ui/widgets/datepicker", "ui/i18n/datepicker-he" -], function( QUnit, $, common, testHelper ) { +], function( QUnit, $, common, helper, testHelper ) { QUnit.module( "datepicker: core", { beforeEach: function() { $( "body" ).trigger( "focus" ); - } + }, + afterEach: helper.moduleAfterEach } ); common.testJshint( "widgets/datepicker" ); diff --git a/tests/unit/datepicker/events.js b/tests/unit/datepicker/events.js index 941822ef886..44064ee21ea 100644 --- a/tests/unit/datepicker/events.js +++ b/tests/unit/datepicker/events.js @@ -5,7 +5,9 @@ define( [ "ui/widgets/datepicker" ], function( QUnit, $, testHelper ) { -QUnit.module( "datepicker: events" ); +var beforeAfterEach = testHelper.beforeAfterEach; + +QUnit.module( "datepicker: events", beforeAfterEach() ); var selectedThis = null, selectedDate = null, diff --git a/tests/unit/datepicker/helper.js b/tests/unit/datepicker/helper.js index 7fd149bf156..85485ddf480 100644 --- a/tests/unit/datepicker/helper.js +++ b/tests/unit/datepicker/helper.js @@ -23,6 +23,12 @@ return $.extend( helper, { assert.equal( d1.toString(), d2.toString(), message ); }, + beforeAfterEach: function() { + return { + afterEach: helper.moduleAfterEach + }; + }, + init: function( id, options ) { $.datepicker.setDefaults( $.datepicker.regional[ "" ] ); return $( id ).datepicker( $.extend( { showAnim: "" }, options || {} ) ); diff --git a/tests/unit/datepicker/methods.js b/tests/unit/datepicker/methods.js index 8729c5606f9..fed04ccdd34 100644 --- a/tests/unit/datepicker/methods.js +++ b/tests/unit/datepicker/methods.js @@ -5,7 +5,9 @@ define( [ "ui/widgets/datepicker" ], function( QUnit, $, testHelper ) { -QUnit.module( "datepicker: methods" ); +var beforeAfterEach = testHelper.beforeAfterEach; + +QUnit.module( "datepicker: methods", beforeAfterEach() ); QUnit.test( "destroy", function( assert ) { assert.expect( 35 ); diff --git a/tests/unit/datepicker/options.js b/tests/unit/datepicker/options.js index 7711e741233..d70220955a5 100644 --- a/tests/unit/datepicker/options.js +++ b/tests/unit/datepicker/options.js @@ -9,7 +9,9 @@ define( [ "ui/ie" ], function( QUnit, $, testHelper ) { -QUnit.module( "datepicker: options" ); +var beforeAfterEach = testHelper.beforeAfterEach; + +QUnit.module( "datepicker: options", beforeAfterEach() ); QUnit.test( "setDefaults", function( assert ) { assert.expect( 3 ); diff --git a/tests/unit/dialog/core.js b/tests/unit/dialog/core.js index 9e89eaa0f57..169734f1c96 100644 --- a/tests/unit/dialog/core.js +++ b/tests/unit/dialog/core.js @@ -1,11 +1,12 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/dialog" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -// TODO add teardown callback to remove dialogs -QUnit.module( "dialog: core" ); +// TODO add afterEach callback to remove dialogs +QUnit.module( "dialog: core", { afterEach: helper.moduleAfterEach } ); QUnit.test( "markup structure", function( assert ) { assert.expect( 11 ); diff --git a/tests/unit/dialog/deprecated.js b/tests/unit/dialog/deprecated.js index eac0e123d55..ab49fe75691 100644 --- a/tests/unit/dialog/deprecated.js +++ b/tests/unit/dialog/deprecated.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/dialog" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "dialog (deprecated): options" ); +QUnit.module( "dialog (deprecated): options", { afterEach: helper.moduleAfterEach } ); QUnit.test( "dialogClass", function( assert ) { assert.expect( 5 ); diff --git a/tests/unit/dialog/events.js b/tests/unit/dialog/events.js index a5030a9f4f4..a98d1396df1 100644 --- a/tests/unit/dialog/events.js +++ b/tests/unit/dialog/events.js @@ -5,7 +5,7 @@ define( [ "ui/widgets/dialog" ], function( QUnit, $, testHelper ) { -QUnit.module( "dialog: events" ); +QUnit.module( "dialog: events", { afterEach: testHelper.moduleAfterEach } ); QUnit.test( "open", function( assert ) { assert.expect( 13 ); diff --git a/tests/unit/dialog/methods.js b/tests/unit/dialog/methods.js index a3e63ce7ad0..e289d81a7ab 100644 --- a/tests/unit/dialog/methods.js +++ b/tests/unit/dialog/methods.js @@ -1,12 +1,14 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/dialog" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { QUnit.module( "dialog: methods", { afterEach: function() { $( "body>.ui-dialog" ).remove(); + return helper.moduleAfterEach.apply( this, arguments ); } } ); diff --git a/tests/unit/dialog/options.js b/tests/unit/dialog/options.js index 4d8e4f7171c..078d32f8d23 100644 --- a/tests/unit/dialog/options.js +++ b/tests/unit/dialog/options.js @@ -1,13 +1,14 @@ define( [ "qunit", "jquery", + "lib/helper", "./helper", "ui/widgets/dialog", "ui/effects/effect-blind", "ui/effects/effect-explode" -], function( QUnit, $, testHelper ) { +], function( QUnit, $, helper, testHelper ) { -QUnit.module( "dialog: options" ); +QUnit.module( "dialog: options", { afterEach: helper.moduleAfterEach } ); QUnit.test( "appendTo", function( assert ) { assert.expect( 16 ); diff --git a/tests/unit/draggable/core.js b/tests/unit/draggable/core.js index 1dd6f572a98..b5dec8104a8 100644 --- a/tests/unit/draggable/core.js +++ b/tests/unit/draggable/core.js @@ -1,13 +1,14 @@ define( [ "qunit", "jquery", + "lib/helper", "./helper", "ui/widgets/draggable", "ui/widgets/droppable", "ui/widgets/resizable" -], function( QUnit, $, testHelper ) { +], function( QUnit, $, helper, testHelper ) { -QUnit.module( "draggable: core" ); +QUnit.module( "draggable: core", { afterEach: helper.moduleAfterEach } ); QUnit.test( "element types", function( assert ) { var typeNames = ( diff --git a/tests/unit/draggable/events.js b/tests/unit/draggable/events.js index f8c4a655122..c2575492306 100644 --- a/tests/unit/draggable/events.js +++ b/tests/unit/draggable/events.js @@ -1,8 +1,9 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/draggable" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { var element; @@ -12,6 +13,7 @@ QUnit.module( "draggable: events", { }, afterEach: function() { element.draggable( "destroy" ); + return helper.moduleAfterEach.apply( this, arguments ); } } ); diff --git a/tests/unit/draggable/methods.js b/tests/unit/draggable/methods.js index 8e95dac30ed..19c7424a055 100644 --- a/tests/unit/draggable/methods.js +++ b/tests/unit/draggable/methods.js @@ -1,9 +1,10 @@ define( [ "qunit", "jquery", + "lib/helper", "./helper", "ui/widgets/draggable" -], function( QUnit, $, testHelper ) { +], function( QUnit, $, helper, testHelper ) { var element; @@ -13,6 +14,7 @@ QUnit.module( "draggable: methods", { }, afterEach: function() { element.remove(); + return helper.moduleAfterEach.apply( this, arguments ); } } ); diff --git a/tests/unit/draggable/options.js b/tests/unit/draggable/options.js index ff72f9d0230..ffe80ffd54d 100644 --- a/tests/unit/draggable/options.js +++ b/tests/unit/draggable/options.js @@ -1,13 +1,14 @@ define( [ "qunit", "jquery", + "lib/helper", "./helper", "ui/widgets/draggable", "ui/widgets/droppable", "ui/widgets/sortable" -], function( QUnit, $, testHelper ) { +], function( QUnit, $, helper, testHelper ) { -QUnit.module( "draggable: options" ); +QUnit.module( "draggable: options", { afterEach: helper.moduleAfterEach } ); // TODO: This doesn't actually test whether append happened, possibly remove QUnit.test( "{ appendTo: 'parent' }, default, no clone", function( assert ) { diff --git a/tests/unit/droppable/core.js b/tests/unit/droppable/core.js index 3d41e5db838..80764711ed4 100644 --- a/tests/unit/droppable/core.js +++ b/tests/unit/droppable/core.js @@ -1,11 +1,12 @@ define( [ "qunit", "jquery", + "lib/helper", "./helper", "ui/widgets/droppable" -], function( QUnit, $, testHelper ) { +], function( QUnit, $, helper, testHelper ) { -QUnit.module( "droppable: core" ); +QUnit.module( "droppable: core", { afterEach: helper.moduleAfterEach } ); QUnit.test( "element types", function( assert ) { var typeNames = ( "p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form" + diff --git a/tests/unit/droppable/events.js b/tests/unit/droppable/events.js index 8ccd7c87c9d..734aee1dbac 100644 --- a/tests/unit/droppable/events.js +++ b/tests/unit/droppable/events.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/droppable" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "droppable: events" ); +QUnit.module( "droppable: events", { afterEach: helper.moduleAfterEach } ); QUnit.test( "droppable destruction/recreation on drop event", function( assert ) { assert.expect( 1 ); diff --git a/tests/unit/droppable/methods.js b/tests/unit/droppable/methods.js index 433615d1657..3a078224a50 100644 --- a/tests/unit/droppable/methods.js +++ b/tests/unit/droppable/methods.js @@ -1,11 +1,12 @@ define( [ "qunit", "jquery", + "lib/helper", "./helper", "ui/widgets/droppable" -], function( QUnit, $, testHelper ) { +], function( QUnit, $, helper, testHelper ) { -QUnit.module( "droppable: methods" ); +QUnit.module( "droppable: methods", { afterEach: helper.moduleAfterEach } ); QUnit.test( "init", function( assert ) { assert.expect( 5 ); diff --git a/tests/unit/droppable/options.js b/tests/unit/droppable/options.js index 1c164495b97..560de09fed4 100644 --- a/tests/unit/droppable/options.js +++ b/tests/unit/droppable/options.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/droppable" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "droppable: options" ); +QUnit.module( "droppable: options", { afterEach: helper.moduleAfterEach } ); /* Test( "{ accept '*' }, default ", function() { diff --git a/tests/unit/effects/core.js b/tests/unit/effects/core.js index d095bfbd530..7ae56aef5a2 100644 --- a/tests/unit/effects/core.js +++ b/tests/unit/effects/core.js @@ -2,6 +2,7 @@ define( [ "qunit", "jquery", "lib/common", + "lib/helper", "ui/effect", "ui/effects/effect-blind", "ui/effects/effect-bounce", @@ -18,7 +19,7 @@ define( [ "ui/effects/effect-size", "ui/effects/effect-slide", "ui/effects/effect-transfer" -], function( QUnit, $, common ) { +], function( QUnit, $, common, helper ) { QUnit.assert.present = function( value, array, message ) { this.push( jQuery.inArray( value, array ) !== -1, value, array, message ); @@ -34,7 +35,7 @@ var minDuration = 60, // Duration is used for "long" animates where we plan on testing properties during animation duration = 200; -QUnit.module( "effects.core" ); +QUnit.module( "effects.core", { afterEach: helper.moduleAfterEach } ); // TODO: test all signatures of .show(), .hide(), .toggle(). // Look at core's signatures and UI's signatures. @@ -97,7 +98,7 @@ QUnit.test( "removeClass", function( assert ) { assert.equal( "", element[ 0 ].className ); } ); -QUnit.module( "effects.core: animateClass" ); +QUnit.module( "effects.core: animateClass", { afterEach: helper.moduleAfterEach } ); QUnit.test( "animateClass works with borderStyle", function( assert ) { var ready = assert.async(); @@ -273,7 +274,7 @@ QUnit.test( "createPlaceholder: preserves layout affecting properties", function assert.deepEqual( before.outerHeight, placeholder.outerHeight( true ), "height preserved" ); } ); -QUnit.module( "transfer" ); +QUnit.module( "transfer", { afterEach: helper.moduleAfterEach } ); QUnit.test( "transfer() without callback", function( assert ) { var ready = assert.async(); diff --git a/tests/unit/effects/scale.js b/tests/unit/effects/scale.js index 44a59234b80..c6b0c9aa3c1 100644 --- a/tests/unit/effects/scale.js +++ b/tests/unit/effects/scale.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/effects/effect-scale" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "effect.scale: Scale" ); +QUnit.module( "effect.scale: Scale", { afterEach: helper.moduleAfterEach } ); function run( position, v, h, vo, ho ) { var desc = "End Position Correct: " + position + " (" + v + "," + h + ") - origin: (" + vo + "," + ho + ")"; diff --git a/tests/unit/form-reset-mixin/core.js b/tests/unit/form-reset-mixin/core.js index 643f3912bf4..daca4dcf166 100644 --- a/tests/unit/form-reset-mixin/core.js +++ b/tests/unit/form-reset-mixin/core.js @@ -2,9 +2,10 @@ define( [ "qunit", "jquery", "lib/common", + "lib/helper", "ui/widget", "ui/form-reset-mixin" -], function( QUnit, $, common ) { +], function( QUnit, $, common, helper ) { QUnit.module( "widget factory", { beforeEach: function() { @@ -26,6 +27,7 @@ QUnit.module( "widget factory", { afterEach: function() { delete $.ui.testWidget; delete $.fn.testWidget; + return helper.moduleAfterEach.apply( this, arguments ); } } ); diff --git a/tests/unit/menu/core.js b/tests/unit/menu/core.js index 8380d66bdaf..9e7bd19105b 100644 --- a/tests/unit/menu/core.js +++ b/tests/unit/menu/core.js @@ -1,11 +1,12 @@ define( [ "qunit", "jquery", + "lib/helper", "./helper", "ui/widgets/menu" -], function( QUnit, $, testHelper ) { +], function( QUnit, $, helper, testHelper ) { -QUnit.module( "menu: core" ); +QUnit.module( "menu: core", { afterEach: helper.moduleAfterEach } ); QUnit.test( "markup structure", function( assert ) { assert.expect( 11 ); diff --git a/tests/unit/menu/events.js b/tests/unit/menu/events.js index 35eec7851eb..c50c184ecc9 100644 --- a/tests/unit/menu/events.js +++ b/tests/unit/menu/events.js @@ -1,9 +1,10 @@ define( [ "qunit", "jquery", + "lib/helper", "./helper", "ui/widgets/menu" -], function( QUnit, $, testHelper ) { +], function( QUnit, $, helper, testHelper ) { var log = testHelper.log, logOutput = testHelper.logOutput, @@ -12,7 +13,8 @@ var log = testHelper.log, QUnit.module( "menu: events", { beforeEach: function() { testHelper.clearLog(); - } + }, + afterEach: helper.moduleAfterEach } ); QUnit.test( "handle click on menu", function( assert ) { diff --git a/tests/unit/menu/methods.js b/tests/unit/menu/methods.js index e0e942dd625..a5e5a90e3bc 100644 --- a/tests/unit/menu/methods.js +++ b/tests/unit/menu/methods.js @@ -1,9 +1,10 @@ define( [ "qunit", "jquery", + "lib/helper", "./helper", "ui/widgets/menu" -], function( QUnit, $, testHelper ) { +], function( QUnit, $, helper, testHelper ) { var log = testHelper.log, logOutput = testHelper.logOutput, @@ -12,7 +13,8 @@ var log = testHelper.log, QUnit.module( "menu: methods", { beforeEach: function() { testHelper.clearLog(); - } + }, + afterEach: helper.moduleAfterEach } ); QUnit.test( "destroy", function( assert ) { diff --git a/tests/unit/menu/options.js b/tests/unit/menu/options.js index 8479b719c37..525c6f01621 100644 --- a/tests/unit/menu/options.js +++ b/tests/unit/menu/options.js @@ -1,9 +1,10 @@ define( [ "qunit", "jquery", + "lib/helper", "./helper", "ui/widgets/menu" -], function( QUnit, $, testHelper ) { +], function( QUnit, $, helper, testHelper ) { var log = testHelper.log, logOutput = testHelper.logOutput, @@ -12,7 +13,8 @@ var log = testHelper.log, QUnit.module( "menu: options", { beforeEach: function() { testHelper.clearLog(); - } + }, + afterEach: helper.moduleAfterEach } ); QUnit.test( "{ disabled: true }", function( assert ) { diff --git a/tests/unit/position/core.js b/tests/unit/position/core.js index 42615a78752..80992a3118c 100644 --- a/tests/unit/position/core.js +++ b/tests/unit/position/core.js @@ -2,8 +2,9 @@ define( [ "qunit", "jquery", "lib/common", + "lib/helper", "ui/position" -], function( QUnit, $, common ) { +], function( QUnit, $, common, helper ) { var win = $( window ), scrollTopSupport = function() { @@ -18,7 +19,8 @@ var win = $( window ), QUnit.module( "position", { beforeEach: function() { win.scrollTop( 0 ).scrollLeft( 0 ); - } + }, + afterEach: helper.moduleAfterEach } ); common.testJshint( "position" ); diff --git a/tests/unit/progressbar/core.js b/tests/unit/progressbar/core.js index b25032a407f..cf9d0aba369 100644 --- a/tests/unit/progressbar/core.js +++ b/tests/unit/progressbar/core.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/progressbar" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "progressbar: core" ); +QUnit.module( "progressbar: core", { afterEach: helper.moduleAfterEach } ); QUnit.test( "markup structure", function( assert ) { assert.expect( 7 ); diff --git a/tests/unit/progressbar/events.js b/tests/unit/progressbar/events.js index be43378a766..e1b33f0b2b2 100644 --- a/tests/unit/progressbar/events.js +++ b/tests/unit/progressbar/events.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/progressbar" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "progressbar: events" ); +QUnit.module( "progressbar: events", { afterEach: helper.moduleAfterEach } ); QUnit.test( "create", function( assert ) { assert.expect( 1 ); diff --git a/tests/unit/progressbar/methods.js b/tests/unit/progressbar/methods.js index 51554937275..8f168f786f8 100644 --- a/tests/unit/progressbar/methods.js +++ b/tests/unit/progressbar/methods.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/progressbar" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "progressbar: methods" ); +QUnit.module( "progressbar: methods", { afterEach: helper.moduleAfterEach } ); QUnit.test( "destroy", function( assert ) { assert.expect( 1 ); diff --git a/tests/unit/progressbar/options.js b/tests/unit/progressbar/options.js index 7ad4c2603d4..fa88ae3c2df 100644 --- a/tests/unit/progressbar/options.js +++ b/tests/unit/progressbar/options.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/progressbar" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "progressbar: options" ); +QUnit.module( "progressbar: options", { afterEach: helper.moduleAfterEach } ); QUnit.test( "{ value: 0 }, default", function( assert ) { assert.expect( 1 ); diff --git a/tests/unit/resizable/core.js b/tests/unit/resizable/core.js index 8c58405e3e9..a2fb6000688 100644 --- a/tests/unit/resizable/core.js +++ b/tests/unit/resizable/core.js @@ -1,11 +1,12 @@ define( [ "qunit", "jquery", + "lib/helper", "./helper", "ui/widgets/resizable" -], function( QUnit, $, testHelper ) { +], function( QUnit, $, helper, testHelper ) { -QUnit.module( "resizable: core" ); +QUnit.module( "resizable: core", { afterEach: helper.moduleAfterEach } ); /* Test("element types", function() { diff --git a/tests/unit/resizable/events.js b/tests/unit/resizable/events.js index 4e396872612..3a94d7e526c 100644 --- a/tests/unit/resizable/events.js +++ b/tests/unit/resizable/events.js @@ -1,11 +1,12 @@ define( [ "qunit", "jquery", + "lib/helper", "./helper", "ui/widgets/resizable" -], function( QUnit, $, testHelper ) { +], function( QUnit, $, helper, testHelper ) { -QUnit.module( "resizable: events" ); +QUnit.module( "resizable: events", { afterEach: helper.moduleAfterEach } ); QUnit.test( "start", function( assert ) { diff --git a/tests/unit/resizable/methods.js b/tests/unit/resizable/methods.js index 7ee49eee69e..8bdc08c11dd 100644 --- a/tests/unit/resizable/methods.js +++ b/tests/unit/resizable/methods.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/resizable" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "resizable: methods" ); +QUnit.module( "resizable: methods", { afterEach: helper.moduleAfterEach } ); QUnit.test( "disable", function( assert ) { assert.expect( 5 ); diff --git a/tests/unit/resizable/options.js b/tests/unit/resizable/options.js index 81206abf8e8..ec5a8c01089 100644 --- a/tests/unit/resizable/options.js +++ b/tests/unit/resizable/options.js @@ -1,11 +1,12 @@ define( [ "qunit", "jquery", + "lib/helper", "./helper", "ui/widgets/resizable" -], function( QUnit, $, testHelper ) { +], function( QUnit, $, helper, testHelper ) { -QUnit.module( "resizable: options" ); +QUnit.module( "resizable: options", { afterEach: helper.moduleAfterEach } ); QUnit.test( "alsoResize", function( assert ) { assert.expect( 2 ); diff --git a/tests/unit/selectable/events.js b/tests/unit/selectable/events.js index 7f8e2baee8a..1ef45264e26 100644 --- a/tests/unit/selectable/events.js +++ b/tests/unit/selectable/events.js @@ -5,7 +5,7 @@ define( [ "ui/widgets/selectable" ], function( QUnit, $, testHelpers ) { -QUnit.module( "selectable: events" ); +QUnit.module( "selectable: events", { afterEach: testHelpers.moduleAfterEach } ); QUnit.test( "start", function( assert ) { assert.expect( 2 ); diff --git a/tests/unit/selectable/methods.js b/tests/unit/selectable/methods.js index c56c228bcd0..d0dc23e6914 100644 --- a/tests/unit/selectable/methods.js +++ b/tests/unit/selectable/methods.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/selectable" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "selectable: methods" ); +QUnit.module( "selectable: methods", { afterEach: helper.moduleAfterEach } ); QUnit.test( "init", function( assert ) { assert.expect( 5 ); diff --git a/tests/unit/selectable/options.js b/tests/unit/selectable/options.js index 58d4b6eb573..02c0d2b2a0f 100644 --- a/tests/unit/selectable/options.js +++ b/tests/unit/selectable/options.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/selectable" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "selectable: options" ); +QUnit.module( "selectable: options", { afterEach: helper.moduleAfterEach } ); QUnit.test( "autoRefresh", function( assert ) { assert.expect( 3 ); diff --git a/tests/unit/selectmenu/core.js b/tests/unit/selectmenu/core.js index b0f56f3b34e..0c1c3979ab9 100644 --- a/tests/unit/selectmenu/core.js +++ b/tests/unit/selectmenu/core.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/selectmenu" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "selectmenu: core" ); +QUnit.module( "selectmenu: core", { afterEach: helper.moduleAfterEach } ); QUnit.test( "markup structure", function( assert ) { assert.expect( 7 ); diff --git a/tests/unit/selectmenu/events.js b/tests/unit/selectmenu/events.js index ffc0429eede..90f40895b59 100644 --- a/tests/unit/selectmenu/events.js +++ b/tests/unit/selectmenu/events.js @@ -1,13 +1,15 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/selectmenu" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { QUnit.module( "selectmenu: events", { beforeEach: function() { this.element = $( "#speed" ); - } + }, + afterEach: helper.moduleAfterEach } ); QUnit.test( "change", function( assert ) { diff --git a/tests/unit/selectmenu/methods.js b/tests/unit/selectmenu/methods.js index 2722fed0194..0785d48adf0 100644 --- a/tests/unit/selectmenu/methods.js +++ b/tests/unit/selectmenu/methods.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/selectmenu" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "selectmenu: methods" ); +QUnit.module( "selectmenu: methods", { afterEach: helper.moduleAfterEach } ); QUnit.test( "destroy", function( assert ) { assert.expect( 1 ); diff --git a/tests/unit/selectmenu/options.js b/tests/unit/selectmenu/options.js index 193ea688e88..b41f120db4f 100644 --- a/tests/unit/selectmenu/options.js +++ b/tests/unit/selectmenu/options.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/selectmenu" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "selectmenu: options" ); +QUnit.module( "selectmenu: options", { afterEach: helper.moduleAfterEach } ); QUnit.test( "appendTo: null", function( assert ) { assert.expect( 1 ); diff --git a/tests/unit/slider/core.js b/tests/unit/slider/core.js index 8031367f0ba..289ddfdd738 100644 --- a/tests/unit/slider/core.js +++ b/tests/unit/slider/core.js @@ -1,8 +1,9 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/slider" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { var element, options; @@ -11,7 +12,7 @@ function handle() { } // Slider Tests -QUnit.module( "slider: core" ); +QUnit.module( "slider: core", { afterEach: helper.moduleAfterEach } ); QUnit.test( "markup structure", function( assert ) { assert.expect( 4 ); diff --git a/tests/unit/slider/events.js b/tests/unit/slider/events.js index d0459db64a4..7250a9ceb59 100644 --- a/tests/unit/slider/events.js +++ b/tests/unit/slider/events.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/slider" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "slider: events" ); +QUnit.module( "slider: events", { afterEach: helper.moduleAfterEach } ); //Specs from http://wiki.jqueryui.com/Slider#specs //"change callback: triggers when the slider has stopped moving and has a new diff --git a/tests/unit/slider/methods.js b/tests/unit/slider/methods.js index ea058cef22b..a2685c60d60 100644 --- a/tests/unit/slider/methods.js +++ b/tests/unit/slider/methods.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/slider" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "slider: methods" ); +QUnit.module( "slider: methods", { afterEach: helper.moduleAfterEach } ); QUnit.test( "init", function( assert ) { assert.expect( 5 ); diff --git a/tests/unit/slider/options.js b/tests/unit/slider/options.js index d1eb2b374d6..e8a9b4208a0 100644 --- a/tests/unit/slider/options.js +++ b/tests/unit/slider/options.js @@ -1,8 +1,9 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/slider" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { var element, options; @@ -10,7 +11,7 @@ function handle() { return element.find( ".ui-slider-handle" ); } -QUnit.module( "slider: options" ); +QUnit.module( "slider: options", { afterEach: helper.moduleAfterEach } ); QUnit.test( "disabled", function( assert ) { assert.expect( 8 ); diff --git a/tests/unit/sortable/core.js b/tests/unit/sortable/core.js index b434e96f09b..f6a26bb3b8a 100644 --- a/tests/unit/sortable/core.js +++ b/tests/unit/sortable/core.js @@ -1,11 +1,12 @@ define( [ "qunit", "jquery", + "lib/helper", "./helper", "ui/widgets/sortable" -], function( QUnit, $, testHelper ) { +], function( QUnit, $, helper, testHelper ) { -QUnit.module( "sortable: core" ); +QUnit.module( "sortable: core", { afterEach: helper.moduleAfterEach } ); QUnit.test( "#9314: Sortable: Items cannot be dragged directly into bottom position", function( assert ) { assert.expect( 1 ); diff --git a/tests/unit/sortable/events.js b/tests/unit/sortable/events.js index 9df830e1654..854c1cfa4da 100644 --- a/tests/unit/sortable/events.js +++ b/tests/unit/sortable/events.js @@ -1,12 +1,13 @@ define( [ "qunit", "jquery", + "lib/helper", "./helper", "ui/widgets/sortable", "ui/widgets/draggable" -], function( QUnit, $, testHelper ) { +], function( QUnit, $, helper, testHelper ) { -QUnit.module( "sortable: events" ); +QUnit.module( "sortable: events", { afterEach: helper.moduleAfterEach } ); QUnit.test( "start", function( assert ) { assert.expect( 7 ); diff --git a/tests/unit/sortable/methods.js b/tests/unit/sortable/methods.js index b52d641ed25..e04fd08ae93 100644 --- a/tests/unit/sortable/methods.js +++ b/tests/unit/sortable/methods.js @@ -1,11 +1,12 @@ define( [ "qunit", "jquery", + "lib/helper", "./helper", "ui/widgets/sortable" -], function( QUnit, $, testHelper ) { +], function( QUnit, $, helper, testHelper ) { -QUnit.module( "sortable: methods" ); +QUnit.module( "sortable: methods", { afterEach: helper.moduleAfterEach } ); QUnit.test( "init", function( assert ) { assert.expect( 5 ); diff --git a/tests/unit/sortable/options.js b/tests/unit/sortable/options.js index 029b442beaf..0df9d0cda32 100644 --- a/tests/unit/sortable/options.js +++ b/tests/unit/sortable/options.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/sortable" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "sortable: options" ); +QUnit.module( "sortable: options", { afterEach: helper.moduleAfterEach } ); /* Test("{ appendTo: 'parent' }, default", function() { diff --git a/tests/unit/spinner/core.js b/tests/unit/spinner/core.js index 526f2ecf86a..6c8c9bdf372 100644 --- a/tests/unit/spinner/core.js +++ b/tests/unit/spinner/core.js @@ -1,13 +1,14 @@ define( [ "qunit", "jquery", + "lib/helper", "./helper", "ui/widgets/spinner" -], function( QUnit, $, testHelper ) { +], function( QUnit, $, helper, testHelper ) { var simulateKeyDownUp = testHelper.simulateKeyDownUp; -QUnit.module( "spinner: core" ); +QUnit.module( "spinner: core", { afterEach: helper.moduleAfterEach } ); QUnit.test( "markup structure", function( assert ) { assert.expect( 6 ); diff --git a/tests/unit/spinner/deprecated.js b/tests/unit/spinner/deprecated.js index baa36acf340..f259ceb2ef9 100644 --- a/tests/unit/spinner/deprecated.js +++ b/tests/unit/spinner/deprecated.js @@ -1,8 +1,9 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/spinner" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { var originalSpinner = $.ui.spinner.prototype; QUnit.module( "spinner: deprecated", { @@ -26,6 +27,7 @@ QUnit.module( "spinner: deprecated", { afterEach: function() { $.ui.spinner.prototype = originalSpinner; + return helper.moduleAfterEach.apply( this, arguments ); } } ); diff --git a/tests/unit/spinner/events.js b/tests/unit/spinner/events.js index 9c69470ab3c..9583a9ec203 100644 --- a/tests/unit/spinner/events.js +++ b/tests/unit/spinner/events.js @@ -1,13 +1,14 @@ define( [ "qunit", "jquery", + "lib/helper", "./helper", "ui/widgets/spinner" -], function( QUnit, $, testHelper ) { +], function( QUnit, $, helper, testHelper ) { var simulateKeyDownUp = testHelper.simulateKeyDownUp; -QUnit.module( "spinner: events" ); +QUnit.module( "spinner: events", { afterEach: helper.moduleAfterEach } ); QUnit.test( "start", function( assert ) { assert.expect( 10 ); diff --git a/tests/unit/spinner/methods.js b/tests/unit/spinner/methods.js index a7af2956db3..8af1a6b6ee0 100644 --- a/tests/unit/spinner/methods.js +++ b/tests/unit/spinner/methods.js @@ -1,13 +1,14 @@ define( [ "qunit", "jquery", + "lib/helper", "./helper", "ui/widgets/spinner" -], function( QUnit, $, testHelper ) { +], function( QUnit, $, helper, testHelper ) { var simulateKeyDownUp = testHelper.simulateKeyDownUp; -QUnit.module( "spinner: methods" ); +QUnit.module( "spinner: methods", { afterEach: helper.moduleAfterEach } ); QUnit.test( "destroy", function( assert ) { assert.expect( 1 ); diff --git a/tests/unit/spinner/options.js b/tests/unit/spinner/options.js index 5b1e5db98f7..7d802b2a433 100644 --- a/tests/unit/spinner/options.js +++ b/tests/unit/spinner/options.js @@ -1,12 +1,13 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/spinner", "globalize", "globalize/ja-JP" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "spinner: options" ); +QUnit.module( "spinner: options", { afterEach: helper.moduleAfterEach } ); // Culture is tested after numberFormat, since it depends on numberFormat diff --git a/tests/unit/tabs/core.js b/tests/unit/tabs/core.js index 0716160bbee..49496dc3748 100644 --- a/tests/unit/tabs/core.js +++ b/tests/unit/tabs/core.js @@ -1,13 +1,14 @@ define( [ "qunit", "jquery", + "lib/helper", "./helper", "ui/widgets/tabs" -], function( QUnit, $, testHelper ) { +], function( QUnit, $, helper, testHelper ) { var state = testHelper.state; -QUnit.module( "tabs: core" ); +QUnit.module( "tabs: core", { afterEach: helper.moduleAfterEach } ); QUnit.test( "markup structure", function( assert ) { assert.expect( 20 ); diff --git a/tests/unit/tabs/events.js b/tests/unit/tabs/events.js index 757e2bada0f..9f7e92d8fdc 100644 --- a/tests/unit/tabs/events.js +++ b/tests/unit/tabs/events.js @@ -1,13 +1,14 @@ define( [ "qunit", "jquery", + "lib/helper", "./helper", "ui/widgets/tabs" -], function( QUnit, $, testHelper ) { +], function( QUnit, $, helper, testHelper ) { var state = testHelper.state; -QUnit.module( "tabs: events" ); +QUnit.module( "tabs: events", { afterEach: helper.moduleAfterEach } ); QUnit.test( "create", function( assert ) { assert.expect( 10 ); diff --git a/tests/unit/tabs/methods.js b/tests/unit/tabs/methods.js index 138f84fca61..c67d76a3114 100644 --- a/tests/unit/tabs/methods.js +++ b/tests/unit/tabs/methods.js @@ -1,14 +1,15 @@ define( [ "qunit", "jquery", + "lib/helper", "./helper", "ui/widgets/tabs" -], function( QUnit, $, testHelper ) { +], function( QUnit, $, helper, testHelper ) { var disabled = testHelper.disabled, state = testHelper.state; -QUnit.module( "tabs: methods" ); +QUnit.module( "tabs: methods", { afterEach: helper.moduleAfterEach } ); QUnit.test( "destroy", function( assert ) { assert.expect( 2 ); diff --git a/tests/unit/tabs/options.js b/tests/unit/tabs/options.js index 3735038434d..8414f79761d 100644 --- a/tests/unit/tabs/options.js +++ b/tests/unit/tabs/options.js @@ -1,15 +1,16 @@ define( [ "qunit", "jquery", + "lib/helper", "./helper", "ui/widgets/tabs" -], function( QUnit, $, testHelper ) { +], function( QUnit, $, helper, testHelper ) { var disabled = testHelper.disabled, equalHeight = testHelper.equalHeight, state = testHelper.state; -QUnit.module( "tabs: options" ); +QUnit.module( "tabs: options", { afterEach: helper.moduleAfterEach } ); QUnit.test( "{ active: default }", function( assert ) { assert.expect( 6 ); diff --git a/tests/unit/tooltip/core.js b/tests/unit/tooltip/core.js index 2de37097af1..e7585d2f9bf 100644 --- a/tests/unit/tooltip/core.js +++ b/tests/unit/tooltip/core.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/tooltip" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "tooltip: core" ); +QUnit.module( "tooltip: core", { afterEach: helper.moduleAfterEach } ); QUnit.test( "markup structure", function( assert ) { assert.expect( 7 ); diff --git a/tests/unit/tooltip/deprecated.js b/tests/unit/tooltip/deprecated.js index bce1a6c6ab5..d4799b29db8 100644 --- a/tests/unit/tooltip/deprecated.js +++ b/tests/unit/tooltip/deprecated.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/tooltip" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "tooltip: (deprecated) options" ); +QUnit.module( "tooltip: (deprecated) options", { afterEach: helper.moduleAfterEach } ); QUnit.test( "tooltipClass", function( assert ) { assert.expect( 1 ); diff --git a/tests/unit/tooltip/events.js b/tests/unit/tooltip/events.js index 3fbb683a588..95808fa669e 100644 --- a/tests/unit/tooltip/events.js +++ b/tests/unit/tooltip/events.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/tooltip" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "tooltip: events" ); +QUnit.module( "tooltip: events", { afterEach: helper.moduleAfterEach } ); QUnit.test( "programmatic triggers", function( assert ) { assert.expect( 4 ); diff --git a/tests/unit/tooltip/methods.js b/tests/unit/tooltip/methods.js index 6e0af2eb4b8..90a9f2a93f3 100644 --- a/tests/unit/tooltip/methods.js +++ b/tests/unit/tooltip/methods.js @@ -1,10 +1,16 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/tooltip" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "tooltip: methods" ); +QUnit.module( "tooltip: methods", { + afterEach: function() { + jQuery.fx.stop(); + return helper.moduleAfterEach.apply( this, arguments ); + } +} ); QUnit.test( "destroy", function( assert ) { assert.expect( 3 ); diff --git a/tests/unit/tooltip/options.js b/tests/unit/tooltip/options.js index 4354d89b3c9..0dbcffd7a98 100644 --- a/tests/unit/tooltip/options.js +++ b/tests/unit/tooltip/options.js @@ -1,10 +1,11 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widgets/tooltip" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { -QUnit.module( "tooltip: options" ); +QUnit.module( "tooltip: options", { afterEach: helper.moduleAfterEach } ); QUnit.test( "disabled: true", function( assert ) { assert.expect( 1 ); diff --git a/tests/unit/widget/animation.js b/tests/unit/widget/animation.js index bbd3ca854a1..dcacec75ca2 100644 --- a/tests/unit/widget/animation.js +++ b/tests/unit/widget/animation.js @@ -1,8 +1,9 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widget" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { QUnit.module( "widget animation", ( function() { var show = $.fn.show, @@ -26,6 +27,7 @@ QUnit.module( "widget animation", ( function() { $.fn.show = show; $.fn.fadeIn = fadeIn; $.fn.slideDown = slideDown; + return helper.moduleAfterEach.apply( this, arguments ); } }; }() ) ); diff --git a/tests/unit/widget/classes.js b/tests/unit/widget/classes.js index 28f61f272e6..357283b5e9f 100644 --- a/tests/unit/widget/classes.js +++ b/tests/unit/widget/classes.js @@ -1,8 +1,9 @@ define( [ "qunit", "jquery", + "lib/helper", "ui/widget" -], function( QUnit, $ ) { +], function( QUnit, $, helper ) { QUnit.module( "widget factory classes", { beforeEach: function() { @@ -50,6 +51,7 @@ QUnit.module( "widget factory classes", { _destroy: function() { this.span.remove(); this.element.unwrap(); + return helper.moduleAfterEach.apply( this, arguments ); } } ); }, diff --git a/tests/unit/widget/core.js b/tests/unit/widget/core.js index 283b5541659..9e69a925371 100644 --- a/tests/unit/widget/core.js +++ b/tests/unit/widget/core.js @@ -2,8 +2,9 @@ define( [ "qunit", "jquery", "lib/common", + "lib/helper", "ui/widget" -], function( QUnit, $, common ) { +], function( QUnit, $, common, helper ) { QUnit.module( "widget factory", { afterEach: function() { @@ -11,6 +12,7 @@ QUnit.module( "widget factory", { delete $.ui.testWidget; delete $.fn.testWidget; } + return helper.moduleAfterEach.apply( this, arguments ); } } ); From a6271df41b80bbed3a450a44d5ac66bb84c235cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Go=C5=82e=CC=A8biowski-Owczarek?= Date: Wed, 13 May 2020 23:16:46 +0200 Subject: [PATCH 4/4] Tests: Add a tooltip test helper cleaning up leftover timers --- tests/unit/draggable/options.js | 3 +++ tests/unit/sortable/options.js | 4 ++++ tests/unit/tooltip/core.js | 8 +++++--- tests/unit/tooltip/deprecated.js | 8 +++++--- tests/unit/tooltip/events.js | 8 +++++--- tests/unit/tooltip/helper.js | 31 +++++++++++++++++++++++++++++++ tests/unit/tooltip/methods.js | 13 +++++-------- tests/unit/tooltip/options.js | 8 +++++--- 8 files changed, 63 insertions(+), 20 deletions(-) create mode 100644 tests/unit/tooltip/helper.js diff --git a/tests/unit/draggable/options.js b/tests/unit/draggable/options.js index ffe80ffd54d..32963b3f672 100644 --- a/tests/unit/draggable/options.js +++ b/tests/unit/draggable/options.js @@ -302,6 +302,9 @@ QUnit.test( "connectToSortable, dragging out of a sortable", function( assert ) dx: dx, dy: dy } ); + + // Cleanup + element.stop( true ); } ); QUnit.test( "connectToSortable, dragging clone into sortable", function( assert ) { diff --git a/tests/unit/sortable/options.js b/tests/unit/sortable/options.js index 0df9d0cda32..06c040be1bb 100644 --- a/tests/unit/sortable/options.js +++ b/tests/unit/sortable/options.js @@ -105,6 +105,10 @@ QUnit.test( "#7415: Incorrect revert animation with axis: 'y'", function( assert var top = parseFloat( item.css( "top" ) ); assert.equal( item.css( "left" ), expectedLeft, "left not animated" ); assert.ok( top > 0 && top < 300, "top is animated" ); + + // Cleanup + item.stop( true ); + ready(); }, 100 ); } ); diff --git a/tests/unit/tooltip/core.js b/tests/unit/tooltip/core.js index e7585d2f9bf..c50164efa67 100644 --- a/tests/unit/tooltip/core.js +++ b/tests/unit/tooltip/core.js @@ -1,11 +1,13 @@ define( [ "qunit", "jquery", - "lib/helper", + "./helper", "ui/widgets/tooltip" -], function( QUnit, $, helper ) { +], function( QUnit, $, testHelper ) { -QUnit.module( "tooltip: core", { afterEach: helper.moduleAfterEach } ); +var beforeAfterEach = testHelper.beforeAfterEach; + +QUnit.module( "tooltip: core", beforeAfterEach() ); QUnit.test( "markup structure", function( assert ) { assert.expect( 7 ); diff --git a/tests/unit/tooltip/deprecated.js b/tests/unit/tooltip/deprecated.js index d4799b29db8..b44b8dcd6ad 100644 --- a/tests/unit/tooltip/deprecated.js +++ b/tests/unit/tooltip/deprecated.js @@ -1,11 +1,13 @@ define( [ "qunit", "jquery", - "lib/helper", + "./helper", "ui/widgets/tooltip" -], function( QUnit, $, helper ) { +], function( QUnit, $, testHelper ) { -QUnit.module( "tooltip: (deprecated) options", { afterEach: helper.moduleAfterEach } ); +var beforeAfterEach = testHelper.beforeAfterEach; + +QUnit.module( "tooltip: (deprecated) options", beforeAfterEach() ); QUnit.test( "tooltipClass", function( assert ) { assert.expect( 1 ); diff --git a/tests/unit/tooltip/events.js b/tests/unit/tooltip/events.js index 95808fa669e..1e83c5255ba 100644 --- a/tests/unit/tooltip/events.js +++ b/tests/unit/tooltip/events.js @@ -1,11 +1,13 @@ define( [ "qunit", "jquery", - "lib/helper", + "./helper", "ui/widgets/tooltip" -], function( QUnit, $, helper ) { +], function( QUnit, $, testHelper ) { -QUnit.module( "tooltip: events", { afterEach: helper.moduleAfterEach } ); +var beforeAfterEach = testHelper.beforeAfterEach; + +QUnit.module( "tooltip: events", beforeAfterEach() ); QUnit.test( "programmatic triggers", function( assert ) { assert.expect( 4 ); diff --git a/tests/unit/tooltip/helper.js b/tests/unit/tooltip/helper.js new file mode 100644 index 00000000000..01d4c03ac98 --- /dev/null +++ b/tests/unit/tooltip/helper.js @@ -0,0 +1,31 @@ +define( [ + "qunit", + "jquery", + "lib/helper", + "ui/widgets/tooltip" +], function( QUnit, $, helper ) { + + return $.extend( helper, { + beforeAfterEach: function() { + return { + afterEach: function() { + var index, timer, + timers = jQuery.timers; + + jQuery.fx.stop(); + var x = false; + + for ( index = timers.length; index--; ) { + x = true; + timer = timers[ index ]; + timer.anim.stop(); + timers.splice( index, 1 ); + } + + return helper.moduleAfterEach.apply( this, arguments ); + } + }; + } + } ); + +} ); diff --git a/tests/unit/tooltip/methods.js b/tests/unit/tooltip/methods.js index 90a9f2a93f3..d71c5e0a64d 100644 --- a/tests/unit/tooltip/methods.js +++ b/tests/unit/tooltip/methods.js @@ -1,16 +1,13 @@ define( [ "qunit", "jquery", - "lib/helper", + "./helper", "ui/widgets/tooltip" -], function( QUnit, $, helper ) { +], function( QUnit, $, testHelper ) { -QUnit.module( "tooltip: methods", { - afterEach: function() { - jQuery.fx.stop(); - return helper.moduleAfterEach.apply( this, arguments ); - } -} ); +var beforeAfterEach = testHelper.beforeAfterEach; + +QUnit.module( "tooltip: methods", beforeAfterEach() ); QUnit.test( "destroy", function( assert ) { assert.expect( 3 ); diff --git a/tests/unit/tooltip/options.js b/tests/unit/tooltip/options.js index 0dbcffd7a98..b9c056388d9 100644 --- a/tests/unit/tooltip/options.js +++ b/tests/unit/tooltip/options.js @@ -1,11 +1,13 @@ define( [ "qunit", "jquery", - "lib/helper", + "./helper", "ui/widgets/tooltip" -], function( QUnit, $, helper ) { +], function( QUnit, $, testHelper ) { -QUnit.module( "tooltip: options", { afterEach: helper.moduleAfterEach } ); +var beforeAfterEach = testHelper.beforeAfterEach; + +QUnit.module( "tooltip: options", beforeAfterEach() ); QUnit.test( "disabled: true", function( assert ) { assert.expect( 1 );