0

I am creating the test case for the component but i got above error in the cmd after ng test.i have tried each and everything but nothing solution worked for me check below code snippet in which i have shared the function which need to be tested

//function to be tested
listDataViaKey(event: any, data: any, tabName: string) {
    let url:string
    switch (tabName) {
      case 'flight':
        url = TESTURL.getInformationById + data.Guid;
        this.flightInfoSubsription = this.httpService.get(url)
          .subscribe((resp:any) => {
            this.flightsInfo = resp.apiData[0].ApiData;
            this.editScreen = true;
          });
        break;
      case 'bus':
        url = TESTURL.getBusInfomationById + data._id;
        this.aircraftSubscription = this.httpService.get(url)
          .subscribe((resp: any) => {
            this.busInfo = resp.apiData[0].ApiData;
            this.editAircraftScreen =true;
          })
        break;
    }
  }
  
  //Unit testing code
  it('should call listViewClick for flight', () => {
    const data = {Guid:'121'};
    const res = { apiData: [{ ApiData: { type: 'test3'}}]};
    component.listViewClick('',data,'flight');
    const req = httpMock.expectOne(APPURL.getInformationById + data.Guid);
    expect(component.editAircraftScreen).toBeTruthy();
  });
  

can anybody help me that how to fix above error?

Kapil Soni
  • 1,003
  • 2
  • 15
  • 37

0 Answers0