test that clicks bound to labeled checkbox input are fired by label clicks

This commit is contained in:
John Bender 2011-10-25 10:55:13 -07:00
parent 4daed58a16
commit 6549b42ab5
2 changed files with 28 additions and 0 deletions

View file

@ -121,4 +121,25 @@
test( "checkboxradio elements in the keepNative set shouldn't be enhanced", function() {
ok( !$("input.should-be-native").parent().is("div.ui-checkbox") );
});
asyncTest( "clicking the label triggers a click on the element", function() {
var clicked = false;
expect( 1 );
$( "#checkbox-click-triggered" ).one('click', function() {
clicked = true;
});
$.testHelper.sequence([
function() {
$( "[for='checkbox-click-triggered']" ).click();
},
function() {
ok(clicked, "click was fired on input");
start();
}
], 2000);
});
})(jQuery);

View file

@ -83,6 +83,13 @@
</fieldset>
</div>
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<legend>Agree to the terms:</legend>
<input type="checkbox" name="checkbox-click-triggered" id="checkbox-click-triggered"/>
<label for="checkbox-click-triggered">click triggered</label>
</fieldset>
</div>
</div>
<div id="enhancetest">