diff options
author | Lorraine Welch <lb2391@att.com> | 2020-02-27 15:17:01 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-02-27 15:17:01 +0000 |
commit | 2256289999dd1d6ffb1bd95568da3a37a115b630 (patch) | |
tree | d40780ce2c3e86227786e6b88e291a8dfad5f3c1 | |
parent | b79d38f79feb3dbf4cd2f4025826d94770527ac9 (diff) | |
parent | eb46569f894f578fea785640905ed732199a5223 (diff) |
Merge "wrote test case for run-dashboard-report component"
-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 |