1 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 import { MatTableModule } from '@angular/material';
3 import { RunDashboardReportComponent } from './run-dashboard-report.component';
4 import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
5 import { RouterModule } from '@angular/router';
6 import { HttpClientTestingModule } from '@angular/common/http/testing';
7 import { RouterTestingModule } from '@angular/router/testing';
8 import { DashboardReportService } from './dashboard-report.service';
10 describe('RunDashboardReportComponent', () => {
11 let component: RunDashboardReportComponent;
12 let fixture: ComponentFixture<RunDashboardReportComponent>;
13 let dashboardService : DashboardReportService;
15 beforeEach(async(() => {
16 TestBed.configureTestingModule({
17 schemas: [CUSTOM_ELEMENTS_SCHEMA],
18 declarations: [ RunDashboardReportComponent ],
19 imports: [MatTableModule, RouterTestingModule, HttpClientTestingModule],
20 providers: [DashboardReportService]
23 dashboardService = TestBed.get(DashboardReportService);
27 fixture = TestBed.createComponent(RunDashboardReportComponent);
28 component = fixture.componentInstance;
29 fixture.detectChanges();
32 it('should create', () => {
33 expect(component).toBeTruthy();
34 fixture.detectChanges();
37 it('should test ngOnInit method', () => {
38 component.queryString = "test";
40 expect(component.initialQueryString).toEqual("test");
41 expect(component.initCounter).toEqual(component.initCounter++);
42 spyOn(component, 'initialProcesses');
43 component.initialProcesses();
44 expect(component.initialProcesses).toHaveBeenCalled();
47 it('should test initialProcess method', () => {
48 component.initialProcesses();
49 expect(component.dataSource.paginator).toEqual(component.paginator);
52 it('should test ngOnChanges method', () => {
53 component.initialQueryString !== component.queryString;
54 component.initCounter > 0;
55 component.runButtonHitCounter !== component.hitCnt;
57 component.ngOnChanges();
58 expect(component.initialQueryString).toEqual(component.queryString);
59 expect(component.runButtonHitCounter).toEqual(component.hitCnt);
61 spyOn(component, 'initialProcesses');
62 spyOn(component, 'afterViewInitProcesses');
63 component.initialProcesses();
64 component.afterViewInitProcesses();
65 expect(component.initialProcesses).toHaveBeenCalled();
66 expect(component.afterViewInitProcesses).toHaveBeenCalled();
70 it('should test afterViewInitProcesses method', () => {
71 component.afterViewInitProcesses();
72 expect(component.displayedColumnsArr).toEqual(new Array());
73 expect(component.displayedRowObj).toEqual(new Array());
74 expect(component.displayedColumns).toEqual(new Array());
75 expect(component.formFieldList).toEqual(new Array());
76 expect(component.showSpinner).toEqual(true);
77 expect(component.isReady).toEqual(false);
78 expect(component.NEWdisplayedColumns).toEqual(new Array());
80 dashboardService.getReportDataWithFormFields("dummy", "test").subscribe((Response) => {
81 expect(component.formFieldPresent).toEqual(false);
82 expect(component.responseFormFieldListLength).toEqual(0);
83 expect(component.reportName).toEqual(Response["reportName"]);
87 it('should test applyFilter method', () => {
88 component.applyFilter("testing");
89 expect(component.dataSource.filter).toEqual("testing".trim().toLowerCase());