I have this function
daysClick: function(e) {
var parent = $(e.currentTarget).closest('.days');
if (!$(parent).hasClass('disabled') && !$(parent).hasClass('readonly')) {
$(e.currentTarget).toggleClass('selected');
}
}
How can I test this using jasmine?
I'm not sure how to fake click event basically.
Have a look at uitest.js .
It allows you to incorporate event handling and other UI features into your automated Jasmine tests.
var uit = uitest.current;
describe('someSuite', function() {
uit.url('someUrl');
it('should do smth when clicked on the button', function() {
uit.runs(function($) {
$(".btn").click();
});
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.