| 1 | define( [ |
| 2 | "qunit", |
| 3 | "jquery", |
| 4 | "lib/helper", |
| 5 | "ui/widgets/checkboxradio" |
| 6 | ], function( QUnit, $, helper ) { |
| 7 | "use strict"; |
| 8 | |
| 9 | QUnit.module( "Checkboxradio: events", { afterEach: helper.moduleAfterEach } ); |
| 10 | |
| 11 | QUnit.test( |
| 12 | "Resetting a checkbox's form should refresh the visual state of the checkbox", |
| 13 | function( assert ) { |
| 14 | var ready = assert.async(); |
| 15 | assert.expect( 2 ); |
| 16 | var form = $( "<form>" + |
| 17 | "<label for='c1'></label><input id='c1' type='checkbox' checked>" + |
| 18 | "</form>" ), |
| 19 | checkbox = form.find( "input[type=checkbox]" ).checkboxradio(), |
| 20 | widget = checkbox.checkboxradio( "widget" ); |
| 21 | |
| 22 | checkbox.prop( "checked", false ).checkboxradio( "refresh" ); |
| 23 | assert.lacksClasses( widget, "ui-state-active" ); |
| 24 | |
| 25 | form.get( 0 ).reset(); |
| 26 | |
| 27 | setTimeout( function() { |
| 28 | assert.hasClasses( widget, "ui-state-active" ); |
| 29 | ready(); |
| 30 | }, 1 ); |
| 31 | } |
| 32 | ); |
| 33 | |
| 34 | QUnit.test( "Checkbox shows focus when using keyboard navigation", function( assert ) { |
| 35 | var ready = assert.async(); |
| 36 | assert.expect( 2 ); |
| 37 | var check = $( "#check" ).checkboxradio(), |
| 38 | label = $( "label[for='check']" ); |
| 39 | assert.lacksClasses( label, "ui-state-focus" ); |
| 40 | check.trigger( "focus" ); |
| 41 | setTimeout( function() { |
| 42 | assert.hasClasses( label, "ui-state-focus" ); |
| 43 | ready(); |
| 44 | } ); |
| 45 | } ); |
| 46 | |
| 47 | } ); |