There are spy-specfic matchers that are very handy.
`expect(x).toHaveBeenCalled()` passes if `x` is a spy and was called
`expect(x).toHaveBeenCalledWith(arguments)` passes if `x` is a spy and was called with the specified arguments
`expect(x).not.toHaveBeenCalled()` passes if `x` is a spy and was not called
`expect(x).not.toHaveBeenCalledWith(arguments)` passes if `x` is a spy and was not called with the specified arguments
<small>The old matchers `wasCalled`, `wasNotCalled`, `wasCalledWith`, and `wasNotCalledWith` have been deprecated and will be removed in a future release. Please change your specs to use `toHaveBeenCalled`, `not.toHaveBeenCalled`, `toHaveBeenCalledWith`, and `not.toHaveBeenCalledWith` respectively.</small>
Spies can be trained to respond in a variety of ways when invoked:
`spyOn(x, 'method').andCallThrough()`: spies on AND calls the original function spied on
`spyOn(x, 'method').andReturn(arguments)`: returns passed arguments when spy is called
`spyOn(x, 'method').andThrow(exception)`: throws passed exception when spy is called
`spyOn(x, 'method').andCallFake(function)`: calls passed function when spy is called
Spies have some useful properties:
`callCount`: returns number of times spy was called
`mostRecentCall.args`: returns argument array from last call to spy.
`argsForCall[i]` returns arguments array for call `i` to spy.
Spies are automatically removed after each spec. They may be set in the beforeEach function.