Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gaizka-allende/2c027e3ea9ffec707abec1b5669d3e5e to your computer and use it in GitHub Desktop.
Save gaizka-allende/2c027e3ea9ffec707abec1b5669d3e5e to your computer and use it in GitHub Desktop.
Test preventDefault is called using Jasmine
function aFunction(event) {
event.preventDefault();
}
it("submit is prevented", function() {
var ev = new Event('submit', {'bubbles':true, 'cancelable':false});
spyOn(ev, 'preventDefault');
aFunction(ev);
expect(ev.preventDefault).toHaveBeenCalled();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment