Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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.
  • Loading branch information
mgol committed May 16, 2020
commit 97720a5926c6cab61c07aedc7eea3eb991594ed2
4 changes: 2 additions & 2 deletions tests/unit/accordion/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/accordion/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
7 changes: 4 additions & 3 deletions tests/unit/accordion/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
};
},
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/accordion/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/accordion/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/autocomplete/core.js
Original file line number Diff line number Diff line change
@@ -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 );
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/autocomplete/events.js
Original file line number Diff line number Diff line change
@@ -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" ];

Expand Down
5 changes: 3 additions & 2 deletions tests/unit/autocomplete/methods.js
Original file line number Diff line number Diff line change
@@ -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 );
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/autocomplete/options.js
Original file line number Diff line number Diff line change
@@ -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" ];
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/button/core.js
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
9 changes: 5 additions & 4 deletions tests/unit/button/deprecated.js
Original file line number Diff line number Diff line change
@@ -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" );
Expand All @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/button/events.js
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/button/methods.js
Original file line number Diff line number Diff line change
@@ -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 );
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/button/options.js
Original file line number Diff line number Diff line change
@@ -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 );
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/checkboxradio/core.js
Original file line number Diff line number Diff line change
@@ -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 );
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/checkboxradio/events.js
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/checkboxradio/methods.js
Original file line number Diff line number Diff line change
@@ -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 ) {
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/checkboxradio/options.js
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/controlgroup/core.js
Original file line number Diff line number Diff line change
@@ -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 );
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/controlgroup/methods.js
Original file line number Diff line number Diff line change
@@ -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 );
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/controlgroup/options.js
Original file line number Diff line number Diff line change
@@ -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 );
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" );

Expand Down
5 changes: 3 additions & 2 deletions tests/unit/core/selector.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/datepicker/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/datepicker/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading