2014-08-28 19:16:51 +00:00
|
|
|
define( [
|
2016-04-03 14:53:34 +00:00
|
|
|
"qunit",
|
2014-08-28 19:16:51 +00:00
|
|
|
"jquery",
|
2020-05-16 07:16:24 +00:00
|
|
|
"lib/helper",
|
2015-01-08 02:51:38 +00:00
|
|
|
"ui/widgets/checkboxradio"
|
2020-05-16 07:16:24 +00:00
|
|
|
], function( QUnit, $, helper ) {
|
2021-06-06 22:58:12 +00:00
|
|
|
"use strict";
|
2014-08-28 19:16:51 +00:00
|
|
|
|
2020-05-16 07:16:24 +00:00
|
|
|
QUnit.module( "Checkboxradio: events", { afterEach: helper.moduleAfterEach } );
|
2014-08-28 19:16:51 +00:00
|
|
|
|
2016-04-03 14:53:34 +00:00
|
|
|
QUnit.test(
|
2014-08-28 19:16:51 +00:00
|
|
|
"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 );
|
2014-08-28 19:16:51 +00:00
|
|
|
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() {
|
2014-08-28 19:16:51 +00:00
|
|
|
assert.hasClasses( widget, "ui-state-active" );
|
2016-04-03 14:53:34 +00:00
|
|
|
ready();
|
2014-08-28 19:16:51 +00:00
|
|
|
}, 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" );
|
2020-05-16 06:36:55 +00:00
|
|
|
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
|
|
|
} );
|
|
|
|
} );
|
2014-08-28 19:16:51 +00:00
|
|
|
|
|
|
|
} );
|