DEV Community

Discussion on: Intercepting Http Requests-- Using And Testing Angular's HttpClient

Collapse
 
alisaduncan profile image
Alisa

Thanks, I'm glad you liked it.

I'm assuming you are mocking the authService's acquireToken method. If so, you shouldn't need to mock mergeMap.

I don't know your use case, but if the mergeMap is complicated, should it be part of acquireToken (or pulled out differently) so that it can be tested independently? It sounds like you might have a lot going on in the interceptor.

Best wishes on your project!

Collapse
 
husseinkorly profile image
Hussein Koprly

Thank you Alisa,

yes, I'm trying to mock the auth service which calls acquireToken method that is part of the adal.js library. Because of the method returns an Observable, so I'm chaining mergeMap to acquireToken in order to wait to get the token.

I will try to take it out of the interceptor to make the test easier.

Thanks again