How can I unit test the mergeMap in chained requests like the one in the following service:
import { Injectable } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { mergeMap, delay } from "rxjs/operators";
@Injectable({
providedIn: "root"
})
export class reqService {
constructor(private httpClient: HttpClient) {}
getMultimpleReq() {
return this.httpClient.get(`https://swapi.dev/api/starships/9/`).pipe(
mergeMap(obj => {
console.log("first request", obj);
let filmFromFirstRequest = obj.MGLT;
return this.httpClient
.get(`https://swapi.dev/api/people/${filmFromFirstRequest}/`)
.pipe(delay(1000));
})
);
}
}
Here is the complete app example code on https://stackblitz.com/edit/angular-chainrequests?devtoolsheight=33&file=src/app/reqservice.ts