359bee9f9a18de7a0f18a532e6b97106daf6129d
[portal/sdk.git] /
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';
6
7 import { ReportListComponent } from './report-list.component';
8 import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
9 import { HttpClientTestingModule } from '@angular/common/http/testing';
10 import { RouterTestingModule } from '@angular/router/testing';
11 import { Router } from '@angular/router';
12 import { AllReportsDataSource } from './report-list-datasource';
13
14 describe('ReportListComponent', () => {
15   let component: ReportListComponent;
16   let fixture: ComponentFixture<ReportListComponent>;
17
18   beforeEach(async(() => {
19     TestBed.configureTestingModule({
20       schemas: [CUSTOM_ELEMENTS_SCHEMA],
21       declarations: [ ReportListComponent ],
22       imports: [
23         NoopAnimationsModule,
24         MatPaginatorModule,
25         MatSortModule,
26         MatTableModule,
27         HttpClientTestingModule,
28         RouterTestingModule
29       ]
30     }).compileComponents();
31   }));
32
33   beforeEach(() => {
34     fixture = TestBed.createComponent(ReportListComponent);
35     component = fixture.componentInstance;
36     fixture.detectChanges();
37   });
38
39   it('should compile', () => {
40     expect(component).toBeTruthy();
41   });
42
43   it('should test initializeReportList method', () => {
44     component.initializeReportList();
45     expect(component.showSpinner).toEqual(true);
46     expect(component.dataSource).toEqual(new AllReportsDataSource());
47     expect(component.intermediateDisplayedColumns).toEqual(new Array());
48     expect(component.finalGETObj).toEqual(new Object());
49     expect(component.finalGETObjRowsArr).toEqual(new Array());
50     expect(component.rowArr).toEqual(new Array());
51     expect(component.reportIdArr).toEqual(new Array());
52     expect(component.toggle).toEqual(false);
53     expect(component.toggle1).toEqual(false);
54     expect(component.finalRowArr).toEqual(new Array());
55   });
56
57   it('should test ngOnInit method', () => {
58       component.ngOnInit();
59       expect(component.toggle).toEqual(false);
60   });
61
62   it('should test confirmDelete method', () => {
63     component.confirmDelete("test");
64     expect(component.showDialog).toEqual(true);
65     expect(component.closable).toEqual(true);
66     expect(component.newReportId).toEqual("test");
67   });
68
69   it('should test ngAfterViewInit method', () => {
70      component.ngAfterViewInit();
71      expect(component.dataSource.sort).toEqual(component.sort);
72      expect(component.dataSource.paginator).toEqual(component.paginator);
73      expect(component.table.dataSource).toEqual(component.dataSource); 
74   });
75
76   it('should test displayReport method', () => {
77       component.displayReport("Testing");
78       expect(component.reportId).toEqual("Testing");
79   });
80
81   it('should test runReport method', () => {
82     component.runReport("Test");
83     expect(component.reportId).toEqual("Test");
84   });
85
86   it('should test applyFilter method', () => {
87       component.applyFilter("ABC");
88       expect(component.dataSource1.filter).toEqual("abc");
89
90   });
91
92   it('should test close method', () => {
93       component.close();
94       expect(component.showDialog).toEqual(true);
95       expect(component.closable).toEqual(false);
96   })
97 });