jquery - QUnit - testing plugin method calls, generic statements, etc -
few things know:
- my app heavily uses
- jquery
- jquery plugins (jquery ui, chosen, datatable, etc)
- bootstrap
so new js unit testing , maybe sound very lame have few questions below:
i have started qunit test js code , have used blanket.js code coverage.
blanket js output shows code uncovered. wondering how/what can them covered?
example 1 function resetform(form) { form.reset(); // line shows not covered } example 2 $('a.staticlink').on('click', function(e) { e.preventdefault();// line shows not covered });
similarly generic bootstrap functions show(), hide() show not covered.
even statements have plugin call show not-covered
$(".chosen-select").chosen(); //not covered
any appreciated
what have trigger event manually in test case. in case of example 2 below
$('a.staticlink').trigger('click');
and write assertions based on supposed happen once button clicked. might consider stubbing
external methods using sinon