Skip to content

Commit

Permalink
(890---checkbox-not-clickable) fixed issue #890 and added appropriate…
Browse files Browse the repository at this point in the history
… unit tests
  • Loading branch information
cmcculloh committed Dec 2, 2014
1 parent 282fbb8 commit 32a5701
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion js/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
},

toggle: function(e) {
if (!e || e.currentTarget === e.originalEvent.target) {
if (!e || (e.target === e.originalEvent.target)) {
this.state.checked = !this.state.checked;

this._toggleCheckedState();
Expand Down
21 changes: 17 additions & 4 deletions test/checkbox-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,28 @@ define(function(require){
equal($chk1.is(':disabled'), false, 're-enabled');
});

test("should check/uncheck checkbox", function () {
test("toggle should check/uncheck checkbox", function () {
var $fixture = $(html).appendTo('#qunit-fixture');
var $chk1 = $fixture.find('#Checkbox1');

equal($chk1.is(':checked'), true, 'checked');
equal($chk1.is(':checked'), true, 'starts checked - confirmation by is(:checked)');
$chk1.checkbox('toggle');
equal($chk1.is(':checked'), false, 'unchecked');
equal($chk1.is(':checked'), false, 'calling toggle unchecks - confirmation by is(:checked)');
$chk1.checkbox('toggle');
equal($chk1.is(':checked'), true, 'checked');
equal($chk1.is(':checked'), true, 'calling toggle again ends with checked - confirmation by is(:checked)');

$fixture.remove();
});

test("click should check/uncheck checkbox", function () {
var $fixture = $(html).appendTo('#qunit-fixture');
var $chk1 = $fixture.find('#Checkbox1');

equal($chk1.is(':checked'), true, 'starts checked - confirmation by is(:checked)');
$chk1.trigger('click');
equal($chk1.is(':checked'), false, 'calling click unchecks - confirmation by is(:checked)');
$chk1.trigger('click');
equal($chk1.is(':checked'), true, 'calling click again checks - confirmation by is(:checked)');

$fixture.remove();
});
Expand Down

0 comments on commit 32a5701

Please sign in to comment.