Angular2: hard time unit testing Http requests
To follow up on my article about TypeScript generics in Angular2, I would like to unit test my Stripe client.
It involves mocking the Angular2 Http service, and it's far more complicated than unit testing the Router service. I first tried to inject a mock of the Http service and return custom Observable responses but this led to strange errors and cumbersome code.
I quickly switched to the recommended way, using MockBackend.
The service to test
As a remainder, the service tested is a Stripe client. It makes recursive Http request to Stripe API in order to fetch customers and plans: