jquery-ui/tests/unit/spinner/deprecated.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

45 lines
1.1 KiB
JavaScript

define( [
"qunit",
"jquery",
"lib/helper",
"ui/widgets/spinner"
], function( QUnit, $, helper ) {
var originalSpinner = $.ui.spinner.prototype;
QUnit.module( "spinner: deprecated", {
beforeEach: function() {
$.widget( "ui.spinner", $.ui.spinner, {
_uiSpinnerHtml: function() {
return "<span class='spin-wrap'>";
},
_buttonHtml: function() {
return "" +
"<a class='spin-up'>" +
"<span>&#9650;</span>" +
"</a>" +
"<a>" +
"<span>&#9660;</span>" +
"</a>";
}
} );
},
afterEach: function() {
$.ui.spinner.prototype = originalSpinner;
return helper.moduleAfterEach.apply( this, arguments );
}
} );
QUnit.test( "markup structure - custom", function( assert ) {
assert.expect( 2 );
var element = $( "#spin" ).spinner(),
spinner = element.spinner( "widget" ),
up = spinner.find( ".ui-spinner-up" );
assert.hasClasses( spinner, "ui-spinner ui-widget ui-widget-content spin-wrap", "_uiSpinnerHtml() overides default markup" );
assert.hasClasses( up, "ui-spinner-button ui-spinner-up ui-widget spin-up", "_ButtonHtml() overides default markup" );
} );
} );