Created
July 11, 2016 13:38
-
-
Save gaizka-allende/2c027e3ea9ffec707abec1b5669d3e5e to your computer and use it in GitHub Desktop.
Test preventDefault is called using Jasmine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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