This is great however testing mocking out angularjs service dependencies which return promises was less great!
I want to test this:
What I wanted:
- A way to easily mock the "fetchData" service method
- Capability to assert "fetchData" was called the with right arguments ( using jasmine spies)
- The mock "fetchData" should return a promise so I can call "then" and use utilities such as $q.all
- As little boiler plate code as possible
So I wrote this little helper:
And here is what the full test looks like:
Here is a full working jsfiddle
There's potential to expand this out having more functionality such as dealing with failing promises and giving more control over when the promise is resolved etc. If you think that's a good idea let me know in the comments.
Here is a full working jsfiddle
There's potential to expand this out having more functionality such as dealing with failing promises and giving more control over when the promise is resolved etc. If you think that's a good idea let me know in the comments.