aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/checkboxradio/events.js
blob: 0760a4387f8b999325f78c4eb9dd8cbd509aa8a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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();
	} );
} );

} );