diff options
Diffstat (limited to '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')
-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 | 115 |
1 files changed, 112 insertions, 3 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..e0ea762d 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,40 @@ 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, Router } from '@angular/router'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { RouterTestingModule } from '@angular/router/testing'; +import { DashboardReportService } from './dashboard-report.service'; +import { MockBackend, MockConnection } from '@angular/http/testing'; +import { Http, BaseRequestOptions } from '@angular/http'; +import { Observable } from 'rxjs'; +import 'rxjs/add/observable/empty'; +import 'rxjs/add/observable/of'; +import { environment } from 'src/environments/environment'; describe('RunDashboardReportComponent', () => { let component: RunDashboardReportComponent; let fixture: ComponentFixture<RunDashboardReportComponent>; + let dashboardService : DashboardReportService; + let router: Router; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ RunDashboardReportComponent ] + schemas: [CUSTOM_ELEMENTS_SCHEMA], + declarations: [ RunDashboardReportComponent ], + imports: [MatTableModule, RouterTestingModule, HttpClientTestingModule], + providers:[DashboardReportService, MockBackend, BaseRequestOptions, { + provide: Http, + useFactory: (backend: MockBackend, defaultOptions: BaseRequestOptions) => { + return new Http(backend, defaultOptions); + }, + deps: [MockBackend, BaseRequestOptions], + }] }) .compileComponents(); + dashboardService = TestBed.get(DashboardReportService); + router = TestBed.get(Router); })); beforeEach(() => { @@ -19,7 +43,92 @@ 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 methods if condition', () => { + + component.hitCnt = 1; + component.queryString = "testing" + component.initialQueryString === "test"; + component.initCounter > 0; + component.runButtonHitCounter === 2; + + 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 ngOnChanges methods else condition', () => { + + component.hitCnt = 1; + component.queryString = "testing" + component.initialQueryString === "testing"; + component.initCounter = 0; + component.runButtonHitCounter === 1; + + component.ngOnChanges(); + expect(component.runButtonHitCounter).toBe(component.hitCnt); + expect(component.initialQueryString).toBe(component.queryString); + }); + + it('should test applyFilter method', () => { + component.applyFilter("testing"); + expect(component.dataSource.filter).toEqual("testing".trim().toLowerCase()); + }); + + 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()); + }); + + it('should test linkToReport method', () => { + let reportId = "abc"; + let queryParameters = "def"; + component.linkToReport(reportId, queryParameters); + }); + + it('should test linkToFeedback method', () => { + let reportId = "abc"; + let queryParameters = "def"; + component.linkToFeedback(reportId, queryParameters); + }); + + it('should test linkToMail method', () => { + let mailID = "abc"; + component.linkToMail(mailID); + }); + +});
\ No newline at end of file |