1 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 import { NoopAnimationsModule } from '@angular/platform-browser/animations';
3 import { MatPaginatorModule } from '@angular/material/paginator';
4 import { MatSortModule } from '@angular/material/sort';
5 import { MatTableModule, MatTableDataSource } from '@angular/material/table';
7 import { RunReportComponent, PeriodicElement } from './run-report.component';
8 import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, SimpleChange, SimpleChanges } from '@angular/core';
9 import { MatMenuModule } from '@angular/material';
10 import { HttpClientTestingModule } from '@angular/common/http/testing';
11 import { RouterTestingModule } from '@angular/router/testing';
12 import { RunService } from '../run.service';
13 import { GridsterConfig, GridsterItem, GridType } from 'angular-gridster2';
15 describe('RunReportComponent', () => {
16 let component: RunReportComponent;
17 let fixture: ComponentFixture<RunReportComponent>;
18 const displayedColumnsArr1 = [];
19 const DashboardReportObj1 = [];
20 const trigger = ["a","b"];
21 let change : SimpleChanges;
22 let runService : RunService;
25 beforeEach(async(() => {
26 TestBed.configureTestingModule({
27 schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
28 declarations: [ RunReportComponent ],
35 HttpClientTestingModule,
38 providers: [RunService]
39 }).compileComponents();
40 runService = TestBed.get(RunService);
44 fixture = TestBed.createComponent(RunReportComponent);
45 runService = TestBed.get(RunService);
46 component = fixture.componentInstance;
47 component.DashboardReportObj = DashboardReportObj1;
48 component.displayedColumnsArr = displayedColumnsArr1;
49 component.TriggerFFArr = trigger;
50 component.options = options1;
51 fixture.detectChanges();
54 it('should compile', () => {
55 expect(component).toBeTruthy();
58 it('should test the ngOnChanges method', () => {
59 fixture.detectChanges();
60 component.reportMode !== "Regular";
61 component.initCnt > 0;
62 component.TriggerFFArr.length == 0;
64 component.ngOnChanges(change);
65 expect(component.showMoreVert).toEqual(false);
66 expect(component.initCnt).toEqual(1);
67 expect(component.showDashboardReport).toEqual(false);
68 expect(component.displayedRowObj).toEqual(new Array());
69 expect(component.displayedColumns).toEqual(new Array());
70 expect(component.formFieldList).toEqual(new Array());
71 expect(component.showSpinner).toEqual(true);
72 expect(component.NEWdisplayedColumns).toEqual(new Array());
73 expect(component.isReady).toEqual(false);
75 runService.getReportDataWithFormFields("for", "test").subscribe((Response) => {
76 component.reportMode !== "FormField";
77 expect(component.showMoreVert).toEqual(true);
78 expect(component.showDashboardReport).toEqual(true);
81 component.initialQueryString !== component.queryString;
82 component.initCounter > 0;
83 component.hitCnt !== component.runButtonHitCnt;
84 expect(component.runButtonHitCnt).toEqual(component.hitCnt);
85 expect(component.initialQueryString).toEqual(component.queryString);
88 it('should test initialProcess method', () => {
89 component.initialProcesses();
90 component.DashboardReportObj.length > 0;
91 expect(component.dashboard).toEqual(component.DashboardReportObj);
92 expect(component.hitCnt).toEqual(component.runButtonHitCnt);
93 expect(component.initialQueryString).toEqual(component.queryString);
94 expect(component.initCounter).toEqual(component.initCounter++);
97 it('should test afterViewInitialProcesses method', () => {
98 component.afterViewInitialProcesses();
99 component.DashboardReportObj.length === 0;
100 component.reportMode === "Regular";
101 component.initCnt == 0;
103 expect(component.showMoreVert).toEqual(false);
104 expect(component.displayedColumnsArr).toEqual(new Array());
105 expect(component.displayedRowObj).toEqual(new Array());
106 expect(component.displayedColumns).toEqual(new Array());
107 expect(component.formFieldList).toEqual(new Array());
108 expect(component.showSpinner).toEqual(true);
109 expect(component.isReady).toEqual(false);
110 expect(component.NEWdisplayedColumns).toEqual(new Array());
113 it('should test showError method', () => {
114 let errmsg = "errormessage";
115 let stcktrace = "stacktrace";
116 component.showError("test");
117 expect(component.errorMessage).toEqual("test"[errmsg]);
118 expect(component.stackTrace).toEqual("test"[stcktrace]);
119 expect(component.error).toEqual(true);
120 expect(component.showSpinner).toEqual(false);
124 it('should test openOptions method', () => {
125 component.openOptions();
126 expect(component.openOptionsFlag).toEqual(component.openOptionsFlag);
129 it('should test applyFilter method', () => {
130 let filterValue = "test"
131 component.applyFilter(filterValue);
132 expect(component.dataSource.filter).toEqual(filterValue.trim().toLowerCase());