How do I test that the method has been called in jasmine?
I think you want to use toHaveBeenCalledWith()
:
it("should show that method doSomething is called with zero arguments", function() {
// Ensure the spy was called with the correct number of arguments
// In this case, no arguments
expect(func.doSomething).toHaveBeenCalledWith();
});
If spy function has been called exactly once, use toHaveBeenCalledOnceWith
matcher:
expect(mySpy).toHaveBeenCalledOnceWith('', 'link', "1", "1");
It combines toHaveBeenCalledTimes(1)
and toHaveBeenCalledWith()
matchers.
Coming with Jasmine 3.6
.