spyOn to spy on that event. When I spy on some function it is working fine. Heres what I tried:
describe("Test:", function(){
it("Expects event will be spied: ", function() {
var eventSpy = spyOn(window, 'myEvent').andCallThrough();
expect(eventSpy).toHaveBeenCalled();
//Also tried this:
//expect(eventSpy).not.toHaveBeenCalled();
});
});So I tried both not.toHaveBeenCalled() and toHaveBeenCalled() but it fails in both the cases. So I guess spyOn is unable to spy on the custom event. Is my approach wrong?
don't you have to trigger the event..?
<code>
describe("Test:", function(){ it("Expects event will be spied: ", function() { var eventSpy = spyOn(window, 'myEvent').andCallThrough();
window.trigger('myEvent');
expect(eventSpy).toHaveBeenCalled();
</code>
//david
> --
> You received this message because you are subscribed to the Google Groups "Jasmine" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jasmine-js+...@googlegroups.com.
> To post to this group, send email to jasmi...@googlegroups.com.
> Visit this group at http://groups.google.com/group/jasmine-js.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>