test added for checkbox check and uncheck firing change

This commit is contained in:
John Bender 2011-04-06 13:30:55 -07:00
parent 4dc2560895
commit ceed56fb2a
2 changed files with 40 additions and 10 deletions

View file

@ -26,4 +26,26 @@
ok(!input.attr("checked"), "not checked after click");
ok(!button.hasClass("ui-btn-active"), "no active styles after click");
});
asyncTest( "change events fired on checkbox for both check and uncheck", function(){
var $checkbox = $("#checkbox-2"),
$checkboxLabel = $("[for=checkbox-2]");
$checkbox.unbind("change");
expect( 2 );
$checkbox.change(function(){
ok(true, "change fired on click to check the box");
});
$checkboxLabel.trigger("click");
//test above will be triggered twice as will the start here
$checkbox.change(function(){
start();
});
$checkboxLabel.trigger("click");
});
})(jQuery);

View file

@ -23,17 +23,25 @@
<ol id="qunit-tests">
</ol>
<div id="qunit-fixture">
<div data-nstest-role="page">
<div data-nstest-role="content">
<div data-nstest-role="fieldcontain">
<fieldset data-nstest-role="controlgroup">
<legend>Agree to the terms:</legend>
<input type="checkbox" name="checkbox-1" id="checkbox-1" class="custom" />
<label for="checkbox-1">I agree</label>
</fieldset>
</div>
<div data-nstest-role="page">
<div data-nstest-role="content">
<div data-nstest-role="fieldcontain">
<fieldset data-nstest-role="controlgroup">
<legend>Agree to the terms:</legend>
<input type="checkbox" name="checkbox-1" id="checkbox-1" class="custom"/>
<label for="checkbox-1">I agree</label>
</fieldset>
</div>
<div data-nstest-role="fieldcontain">
<fieldset data-nstest-role="controlgroup">
<legend>Agree to the terms:</legend>
<input type="checkbox" name="checkbox-2" id="checkbox-2" class="custom"/>
<label for="checkbox-2">I agree</label>
</fieldset>
</div>
</div>
</div>
</body>
</html>