From c2e11a10dd1de0c6370576293ecf7e5a3cd470b2 Mon Sep 17 00:00:00 2001 From: Rupinder Date: Fri, 27 Mar 2020 18:40:25 +0530 Subject: added test cases for report-list comp Added more test cases for report-list.component.spec.ts Issue-ID: PORTAL-834 Change-Id: I19bcce53c0f839271d4fd6efd6f11970d38dee9f Signed-off-by: Rupinder --- .../Report_List/report-list.component.spec.ts | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'ecomp-sdk') diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/report-list.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/report-list.component.spec.ts index 2c01ff14..78113e42 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/report-list.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/report-list.component.spec.ts @@ -3,17 +3,27 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { MatPaginatorModule } from '@angular/material/paginator'; import { MatSortModule } from '@angular/material/sort'; import { MatTableModule, MatTableDataSource } from '@angular/material/table'; - import { ReportListComponent } from './report-list.component'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { Router } from '@angular/router'; import { AllReportsDataSource } from './report-list-datasource'; +import { HttpClient } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import 'rxjs/add/observable/empty'; +import 'rxjs/add/observable/of'; +import { environment } from 'src/environments/environment'; +import { ReportListService } from './report-list.service'; describe('ReportListComponent', () => { let component: ReportListComponent; let fixture: ComponentFixture; + let http: HttpClient; + let reportService : ReportListService; + let environment = [ + { baseUrl : 'just for test' } + ] beforeEach(async(() => { TestBed.configureTestingModule({ @@ -25,9 +35,14 @@ describe('ReportListComponent', () => { MatSortModule, MatTableModule, HttpClientTestingModule, - RouterTestingModule - ] + RouterTestingModule, + ], + providers: [HttpClient, ReportListService] }).compileComponents(); + + reportService = TestBed.get(ReportListService); + http = TestBed.get(HttpClient); + spyOn(reportService, 'deleteReport').and.returnValue(Observable.of(environment)); })); beforeEach(() => { @@ -96,7 +111,9 @@ describe('ReportListComponent', () => { }); it('should test deleteReport method', () => { + spyOn(component, 'deleteReport').and.callThrough(); component.deleteReport(); + expect(component.deleteReport).toHaveBeenCalled(); }); it('should test openReportSchedule method', () => { -- cgit 1.2.3-korg