title: Angular mock multiple HTTP calls
body: <p>I have one service which is returning the forkjoin of multiple http calls. I wanted to test this scenario. </p>
  
  <pre><code>    class CommentService{
       addComments(){
  
  let ob1 = Observable.of({});
      let ob2 = Observable.of({});
  if(any condition)
          ob1 = {this.http.post('/url/1')};
  if(any condition)
              ob2 = {this.http.post('/url/2'};
          return Observable.forkJoin(ob1,ob2)
             }
       }
  </code></pre>
  
  <p>Above is my service class. How can i mock the http calls. </p>
  
  <pre><code>describe("CommentService", () =&gt; {
    let httpClient: HttpClient;
    let httpTestingController: HttpTestingController;
    beforeEach(() =&gt; {
      TestBed.configureTestingModule({
        imports: [HttpClientModule, HttpClientTestingModule],
        providers: [CommentService]
      });
  
      httpClient = TestBed.get(HttpClient);
      httpTestingController = TestBed.get(HttpTestingController);
    });
  
    it('addComments() call with normal and gate', inject([CommentService], (service: CommentService) =&gt; {
  
  
      let cmts = service.addComments();
  
      const reqGateComment = httpTestingController.expectOne('/url/1');
      expect(reqGateComment.request.method).toEqual('POST');
  
      const reqFactComment = httpTestingController.expectOne('/url/2');
      expect(reqFactComment.request.method).toEqual('POST');
  
      reqGateComment.flush({});
      reqFactComment.flush({});
  
  
      httpTestingController.verify();
  
      cmts.subscribe(results=&gt;{
         expect(results.length).toEqual(2);
      });
  
    }));
  
  
  });
  </code></pre>
  
  <p>I am getting the below test fail. 
  CommentService addFactsAndComments() call with normal and gate</p>
  
  <p>Error: Expected one matching request for criteria "Match URL: </p>
  
  <pre><code> '/url/1", found none.
  </code></pre>