title: angular 6 unit testing Forkjoin service response
body: <p>i have a function in service in which i have 3 http get calls and i return the response with forkJoin making an array, how will i test this service funtcion in spec.ts ?
  this is the function in my registration component which is calling the service,</p>
  
  <pre><code>this.register.registrationData()
    .subscribe(data =&gt; {
      this.types = data[0];
      this.modules = data[1];
      this.packages = data[2];
    });
  </code></pre>
  
  <p>and this is my registration service function, </p>
  
  <pre><code>registrationData(): Observable&lt;any&gt; {
      const companyTypes =this.http.get(ConstantService.apiRoutes.companyTypes);
      const modules = this.http.get(ConstantService.apiRoutes.modules);
      const packages = this.http.get(ConstantService.apiRoutes.packages);
      return forkJoin([companyTypes, modules, packages]);
  }
  </code></pre>
  
  <p>this is my spec file so far,</p>
  
  <pre><code> it('Should require registration data', () =&gt; {
    loginRegService.registrationData().subscribe((data) =&gt; {
      expect(data).toEqual(regData);
    })
    const reqCompany = httpTestingController.expectOne(`${environment.apiUrl}/anonymous/companyTypes/`);
    const reqModule = httpTestingController.expectOne(`${environment.apiUrl}/anonymous/modules/`);
    const reqPackage = httpTestingController.expectOne(`${environment.apiUrl}/anonymous/packages/`);
    expect(reqCompany.request.method).toBe('GET');
    expect(reqModule.request.method).toBe('GET');
    expect(reqPackage.request.method).toBe('GET');
    const e1 = forkJoin([reqCompany, reqModule, reqPackage]);
    reqCompany.flush(companyType);
    reqModule.flush(modules);
    reqPackage.flush(packages);
  });
  </code></pre>