diff options
author | Lorraine Welch <lb2391@att.com> | 2020-02-27 15:18:12 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-02-27 15:18:12 +0000 |
commit | 1fe7926c797ca4eb839fd323b31b7b9438501878 (patch) | |
tree | 7d25dcd17407ded8d5d73510a085810f75b28b94 /ecomp-sdk/epsdk-app-overlay/src/main | |
parent | c3fa40d14e985a72c4156b91475eb0304dc50b0b (diff) | |
parent | f55be092d6bdc767443297f21f61e281c4033c9f (diff) |
Merge "wrote test case for run-report component"
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src/main')
-rw-r--r-- | ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-report.component.spec.ts | 109 |
1 files changed, 105 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-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-report.component.spec.ts index f1d53d9e..4d4fe269 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-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-report.component.spec.ts @@ -2,33 +2,134 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { MatPaginatorModule } from '@angular/material/paginator'; import { MatSortModule } from '@angular/material/sort'; -import { MatTableModule } from '@angular/material/table'; +import { MatTableModule, MatTableDataSource } from '@angular/material/table'; -import { RunReportComponent } from './run-report.component'; +import { RunReportComponent, PeriodicElement } from './run-report.component'; +import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, SimpleChange, SimpleChanges } from '@angular/core'; +import { MatMenuModule } from '@angular/material'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { RouterTestingModule } from '@angular/router/testing'; +import { RunService } from '../run.service'; +import { GridsterConfig, GridsterItem, GridType } from 'angular-gridster2'; -describe('RunReportFinalTableComponent', () => { +describe('RunReportComponent', () => { let component: RunReportComponent; let fixture: ComponentFixture<RunReportComponent>; + const displayedColumnsArr1 = []; + const DashboardReportObj1 = []; + const trigger = ["a","b"]; + let change : SimpleChanges; + let runService : RunService; + let options1 = {}; beforeEach(async(() => { TestBed.configureTestingModule({ + schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA], declarations: [ RunReportComponent ], imports: [ NoopAnimationsModule, MatPaginatorModule, MatSortModule, MatTableModule, - ] + MatMenuModule, + HttpClientTestingModule, + RouterTestingModule + ], + providers: [RunService] }).compileComponents(); + runService = TestBed.get(RunService); })); beforeEach(() => { fixture = TestBed.createComponent(RunReportComponent); + runService = TestBed.get(RunService); component = fixture.componentInstance; + component.DashboardReportObj = DashboardReportObj1; + component.displayedColumnsArr = displayedColumnsArr1; + component.TriggerFFArr = trigger; + component.options = options1; fixture.detectChanges(); }); it('should compile', () => { expect(component).toBeTruthy(); }); + + it('should test the ngOnChanges method', () => { + fixture.detectChanges(); + component.reportMode !== "Regular"; + component.initCnt > 0; + component.TriggerFFArr.length == 0; + + component.ngOnChanges(change); + expect(component.showMoreVert).toEqual(false); + expect(component.initCnt).toEqual(1); + expect(component.showDashboardReport).toEqual(false); + 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.NEWdisplayedColumns).toEqual(new Array()); + expect(component.isReady).toEqual(false); + + runService.getReportDataWithFormFields("for", "test").subscribe((Response) => { + component.reportMode !== "FormField"; + expect(component.showMoreVert).toEqual(true); + expect(component.showDashboardReport).toEqual(true); + }); + + component.initialQueryString !== component.queryString; + component.initCounter > 0; + component.hitCnt !== component.runButtonHitCnt; + expect(component.runButtonHitCnt).toEqual(component.hitCnt); + expect(component.initialQueryString).toEqual(component.queryString); + }); + + it('should test initialProcess method', () => { + component.initialProcesses(); + component.DashboardReportObj.length > 0; + expect(component.dashboard).toEqual(component.DashboardReportObj); + expect(component.hitCnt).toEqual(component.runButtonHitCnt); + expect(component.initialQueryString).toEqual(component.queryString); + expect(component.initCounter).toEqual(component.initCounter++); + }); + + it('should test afterViewInitialProcesses method', () => { + component.afterViewInitialProcesses(); + component.DashboardReportObj.length === 0; + component.reportMode === "Regular"; + component.initCnt == 0; + + expect(component.showMoreVert).toEqual(false); + 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()); + }); + + it('should test showError method', () => { + let errmsg = "errormessage"; + let stcktrace = "stacktrace"; + component.showError("test"); + expect(component.errorMessage).toEqual("test"[errmsg]); + expect(component.stackTrace).toEqual("test"[stcktrace]); + expect(component.error).toEqual(true); + expect(component.showSpinner).toEqual(false); + + }); + + it('should test openOptions method', () => { + component.openOptions(); + expect(component.openOptionsFlag).toEqual(component.openOptionsFlag); + }); + + it('should test applyFilter method', () => { + let filterValue = "test" + component.applyFilter(filterValue); + expect(component.dataSource.filter).toEqual(filterValue.trim().toLowerCase()); + }); + }); |