mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
e7a10c70ae
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
47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
define( [
|
|
"qunit",
|
|
"jquery",
|
|
"lib/helper",
|
|
"ui/widgets/checkboxradio"
|
|
], function( QUnit, $, helper ) {
|
|
|
|
QUnit.module( "Checkboxradio: events", { afterEach: helper.moduleAfterEach } );
|
|
|
|
QUnit.test(
|
|
"Resetting a checkbox's form should refresh the visual state of the checkbox",
|
|
function( assert ) {
|
|
var ready = assert.async();
|
|
assert.expect( 2 );
|
|
var form = $( "<form>" +
|
|
"<label for='c1'></label><input id='c1' type='checkbox' checked>" +
|
|
"</form>" ),
|
|
checkbox = form.find( "input[type=checkbox]" ).checkboxradio(),
|
|
widget = checkbox.checkboxradio( "widget" );
|
|
|
|
checkbox.prop( "checked", false ).checkboxradio( "refresh" );
|
|
assert.lacksClasses( widget, "ui-state-active" );
|
|
|
|
form.get( 0 ).reset();
|
|
|
|
setTimeout( function() {
|
|
assert.hasClasses( widget, "ui-state-active" );
|
|
ready();
|
|
}, 1 );
|
|
}
|
|
);
|
|
|
|
QUnit.test( "Checkbox shows focus when using keyboard navigation", function( assert ) {
|
|
var ready = assert.async();
|
|
assert.expect( 2 );
|
|
var check = $( "#check" ).checkboxradio(),
|
|
label = $( "label[for='check']" );
|
|
assert.lacksClasses( label, "ui-state-focus" );
|
|
check.trigger( "focus" );
|
|
setTimeout( function() {
|
|
assert.hasClasses( label, "ui-state-focus" );
|
|
ready();
|
|
} );
|
|
} );
|
|
|
|
} );
|