Stubbing e.preventDefault() in a jasmine test
Another way to create mock object (with spies you need) is to use jasmine.createSpyObj()
.
Array containing spy names have to be passed as second parameter.
var e = jasmine.createSpyObj('e', [ 'preventDefault' ]);
this.view.showTopic(e);
expect(e.preventDefault).toHaveBeenCalled();
You have to pass an object with a field preventDefault that holds your spy:
var event = {preventDefault: jasmine.createSpy()}
this.view.showTopic(event);
expect(event.preventDefault).toHaveBeenCalled