jquery-ui/tests/unit/checkboxradio/events.js

47 lines
1.2 KiB
JavaScript
Raw Normal View History

define( [
2016-04-03 14:53:34 +00:00
"qunit",
"jquery",
"lib/helper",
"ui/widgets/checkboxradio"
], function( QUnit, $, helper ) {
QUnit.module( "Checkboxradio: events", { afterEach: helper.moduleAfterEach } );
2016-04-03 14:53:34 +00:00
QUnit.test(
"Resetting a checkbox's form should refresh the visual state of the checkbox",
function( assert ) {
2016-04-03 14:53:34 +00:00
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();
2015-09-11 14:48:20 +00:00
setTimeout( function() {
assert.hasClasses( widget, "ui-state-active" );
2016-04-03 14:53:34 +00:00
ready();
}, 1 );
}
);
2016-04-03 14:53:34 +00:00
QUnit.test( "Checkbox shows focus when using keyboard navigation", function( assert ) {
var ready = assert.async();
assert.expect( 2 );
2015-10-27 20:05:52 +00:00
var check = $( "#check" ).checkboxradio(),
label = $( "label[for='check']" );
assert.lacksClasses( label, "ui-state-focus" );
check.trigger( "focus" );
2015-10-27 20:05:52 +00:00
setTimeout( function() {
assert.hasClasses( label, "ui-state-focus" );
2016-04-03 14:53:34 +00:00
ready();
2015-10-27 20:05:52 +00:00
} );
} );
} );