I have an object with a click listener and try to write tests for it. I have problems using jasmine expect(event).toHaveBeenTriggered()
and it seems the problem is the e.preventDefault
statement.
Listener:
$(document).on("click", "input", function (e) {
e.preventDefault();
// do something
});
Test:
describe("CartViewController", function () {
"use strict";
beforeEach(function () {
setFixtures("<input />");
});
it("should have been triggered", function () {
var input = $('input');
var spyEvent = spyOnEvent(input, 'click' );
$( input ).click();
expect( spyEvent ).toHaveBeenTriggered();
});
});
Is there a way to get toHaveBeenTriggered
to work or disable preventDefault
for testing?
Aucun commentaire:
Enregistrer un commentaire