Test angular directive

Let’s define our directive:

angular unit test with dependency injection - summary

Let the code speak for itself:

angular service test use $provide (DI p3)

After we’ve managed to help jasmine’s spies infiltrate a ‘real’ service that was injected with angular’s dependency-injection mechanism, it’s time to mess up with the DI itself.

angular controller test with DI - use inject (DI p2)

Previously, we’ve seen how to inject a jasmine spyObj as a service directly to a controller, using $controller(). This is easy, since we are creating a new controller for each test, so we can inject different spies to it. But what about testing services?

angular controller unit test with DI (p1)

After we’ve set-up the initial tests for our cute controllers and services, let’ get to the real world. In the real world, controllers user services, and services use services, and everything is just swimming in the big browsers jacuzzi…