diff options
author | Rupinder <rupinsi1@in.ibm.com> | 2020-02-27 18:36:30 +0530 |
---|---|---|
committer | Rupinder <rupinsi1@in.ibm.com> | 2020-02-27 18:36:40 +0530 |
commit | eb46569f894f578fea785640905ed732199a5223 (patch) | |
tree | 98012fc74fae5002bf029baf1b09ee7dba767836 | |
parent | 37db40a2dc6e811e919b912579fbbb2b1d8cedba (diff) |
wrote test case for run-dashboard-report component
Written test cases for run-dashboard-report.component.spec.ts
Issue-ID: PORTAL-834
Change-Id: I8e64c767101dd754b96ac03130012381c29d77f0
Signed-off-by: Rupinder<rupinsi1@in.ibm.com>
-rw-r--r-- | ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/run-dashboard-report.component.spec.ts | 75 |
1 files changed, 71 insertions, 4 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/run-dashboard-report.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/run-dashboard-report.component.spec.ts index 38e7b3ba..96dcdbaa 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/run-dashboard-report.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/run-dashboard-report.component.spec.ts @@ -1,16 +1,26 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - +import { MatTableModule } from '@angular/material'; import { RunDashboardReportComponent } from './run-dashboard-report.component'; +import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { RouterModule } from '@angular/router'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { RouterTestingModule } from '@angular/router/testing'; +import { DashboardReportService } from './dashboard-report.service'; describe('RunDashboardReportComponent', () => { let component: RunDashboardReportComponent; let fixture: ComponentFixture<RunDashboardReportComponent>; + let dashboardService : DashboardReportService; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ RunDashboardReportComponent ] + schemas: [CUSTOM_ELEMENTS_SCHEMA], + declarations: [ RunDashboardReportComponent ], + imports: [MatTableModule, RouterTestingModule, HttpClientTestingModule], + providers: [DashboardReportService] }) .compileComponents(); + dashboardService = TestBed.get(DashboardReportService); })); beforeEach(() => { @@ -19,7 +29,64 @@ describe('RunDashboardReportComponent', () => { fixture.detectChanges(); }); - it('should create', () => { + it('should create', () => { expect(component).toBeTruthy(); + fixture.detectChanges(); + }); + + it('should test ngOnInit method', () => { + component.queryString = "test"; + component.ngOnInit(); + expect(component.initialQueryString).toEqual("test"); + expect(component.initCounter).toEqual(component.initCounter++); + spyOn(component, 'initialProcesses'); + component.initialProcesses(); + expect(component.initialProcesses).toHaveBeenCalled(); + }); + + it('should test initialProcess method', () => { + component.initialProcesses(); + expect(component.dataSource.paginator).toEqual(component.paginator); + }); + + it('should test ngOnChanges method', () => { + component.initialQueryString !== component.queryString; + component.initCounter > 0; + component.runButtonHitCounter !== component.hitCnt; + + component.ngOnChanges(); + expect(component.initialQueryString).toEqual(component.queryString); + expect(component.runButtonHitCounter).toEqual(component.hitCnt); + + spyOn(component, 'initialProcesses'); + spyOn(component, 'afterViewInitProcesses'); + component.initialProcesses(); + component.afterViewInitProcesses(); + expect(component.initialProcesses).toHaveBeenCalled(); + expect(component.afterViewInitProcesses).toHaveBeenCalled(); + + }); + + it('should test afterViewInitProcesses method', () => { + component.afterViewInitProcesses(); + expect(component.displayedColumnsArr).toEqual(new Array()); + expect(component.displayedRowObj).toEqual(new Array()); + expect(component.displayedColumns).toEqual(new Array()); + expect(component.formFieldList).toEqual(new Array()); + expect(component.showSpinner).toEqual(true); + expect(component.isReady).toEqual(false); + expect(component.NEWdisplayedColumns).toEqual(new Array()); + + dashboardService.getReportDataWithFormFields("dummy", "test").subscribe((Response) => { + expect(component.formFieldPresent).toEqual(false); + expect(component.responseFormFieldListLength).toEqual(0); + expect(component.reportName).toEqual(Response["reportName"]); + }); + }); + + it('should test applyFilter method', () => { + component.applyFilter("testing"); + expect(component.dataSource.filter).toEqual("testing".trim().toLowerCase()); }); -}); + +});
\ No newline at end of file |