Skip to content

Commit

Permalink
added testcoverage for jquery-validation#1062.
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Apr 28, 2014
1 parent 6458317 commit c1695d0
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,45 @@ test("submitHandler keeps submitting button", function() {
$("#userForm").submit();
});

test("validation triggered on radio/checkbox when using keyboard", function() {
var input, i, events, triggeredEvents = 0;

$("#form").validate({
debug: true,
onfocusin: function() {
triggeredEvents++;
},
onfocusout: function() {
triggeredEvents++;
},
onkeyup: function() {
triggeredEvents++;
}
});

events = [
$.Event("focusin"),
$.Event("focusout"),
$.Event("keyup")
];

input = $("#form :radio")[0];
for(i = 0; i < events.length; i++) {
$.event.trigger(events[i], null, input);
}

input = $("#form :checkbox")[0];
for(i = 0; i < events.length; i++) {
$.event.trigger(events[i], null, input);
}

setTimeout(function() {
// assert all event handlers fired
equal(6, triggeredEvents);
}, 50);
});


test("showErrors()", function() {
expect( 4 );
var errorLabel = $("#errorFirstname").hide(),
Expand Down

0 comments on commit c1695d0

Please sign in to comment.