2011-02-11 18:26:37 +00:00
|
|
|
/*
|
2011-04-02 06:43:59 +00:00
|
|
|
* mobile checkboxradio unit tests
|
2011-02-11 18:26:37 +00:00
|
|
|
*/
|
2011-02-27 08:00:14 +00:00
|
|
|
(function($){
|
|
|
|
|
module('jquery.mobile.forms.checkboxradio.js');
|
2011-02-11 18:26:37 +00:00
|
|
|
|
2011-02-27 08:00:14 +00:00
|
|
|
test( "widget can be disabled and enabled", function(){
|
|
|
|
|
var input = $("#checkbox-1");
|
|
|
|
|
var button = input.parent().find(".ui-btn");
|
2011-02-11 18:26:37 +00:00
|
|
|
|
2011-02-27 08:00:14 +00:00
|
|
|
input.checkboxradio("disable");
|
|
|
|
|
input.checkboxradio("enable");
|
|
|
|
|
ok(!input.attr("disabled"), "start input as enabled");
|
|
|
|
|
ok(!input.parent().hasClass("ui-disabled"), "no disabled styles");
|
|
|
|
|
ok(!input.attr("checked"), "not checked before click");
|
2011-03-29 16:32:10 +00:00
|
|
|
button.trigger("click");
|
2011-02-27 08:00:14 +00:00
|
|
|
ok(input.attr("checked"), "checked after click");
|
|
|
|
|
ok(button.hasClass("ui-btn-active"), "active styles after click");
|
2011-03-29 16:32:10 +00:00
|
|
|
button.trigger("click");
|
2011-02-11 18:26:37 +00:00
|
|
|
|
2011-02-27 08:00:14 +00:00
|
|
|
input.checkboxradio("disable");
|
|
|
|
|
ok(input.attr("disabled"), "input disabled");
|
|
|
|
|
ok(input.parent().hasClass("ui-disabled"), "disabled styles");
|
|
|
|
|
ok(!input.attr("checked"), "not checked before click");
|
2011-03-29 16:32:10 +00:00
|
|
|
button.trigger("click");
|
2011-02-27 08:00:14 +00:00
|
|
|
ok(!input.attr("checked"), "not checked after click");
|
|
|
|
|
ok(!button.hasClass("ui-btn-active"), "no active styles after click");
|
|
|
|
|
});
|
2011-04-06 20:30:55 +00:00
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
|
2011-04-06 20:33:32 +00:00
|
|
|
//test above will be triggered twice, and the start here once
|
2011-04-06 20:30:55 +00:00
|
|
|
$checkbox.change(function(){
|
|
|
|
|
start();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$checkboxLabel.trigger("click");
|
|
|
|
|
});
|
2011-03-29 16:32:10 +00:00
|
|
|
})(jQuery);
|