c922b3593c034a1564c369fc9e183e224910b289
[portal/sdk.git] /
1 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 import {FormsModule} from '@angular/forms';
3 import { RunReportFormFieldsComponent } from './run-report-form-fields.component';
4 import { CUSTOM_ELEMENTS_SCHEMA, Component } from '@angular/core';
5 import {MatDatepickerModule} from '@angular/material/datepicker'; 
6 import { HttpClientTestingModule } from '@angular/common/http/testing';
7 import { RouterTestingModule } from '@angular/router/testing';
8
9 describe('RunReportFormFieldsComponent', () => {
10   let component: RunReportFormFieldsComponent;
11   let fixture: ComponentFixture<RunReportFormFieldsComponent>;
12   let formfield =[{"validationType":1},{},{}] ;
13
14   beforeEach(async(() => {
15     TestBed.configureTestingModule({
16       schemas: [CUSTOM_ELEMENTS_SCHEMA],
17       imports: [FormsModule, MatDatepickerModule, HttpClientTestingModule, RouterTestingModule],
18       declarations: [ RunReportFormFieldsComponent ]
19     })
20     .compileComponents();
21   }));
22
23   beforeEach(() => {
24     fixture = TestBed.createComponent(RunReportFormFieldsComponent);
25     component = fixture.componentInstance;
26      component.formFieldList = formfield;
27     fixture.detectChanges();
28   });
29
30   it('should create', () => {
31     expect(component).toBeTruthy();
32   });
33
34   it('should test ngOnInit method', () => {
35         component.ngOnInit();
36         // expect(component.showSpinner).toEqual(true);
37         // expect(component.navigateToRun).toEqual(false);
38   });
39
40   it('should test convertDate method', () => {
41       component.convertDate("test");
42   });
43
44   it('should test getQueryString methods', () => {
45     component.directCallQueryParams = 'abc';    
46     component.getQueryString();
47     expect(component.getQueryString()).toEqual(component.directCallQueryParams);
48
49     component.directCallQueryParams = "";    
50     component.getQueryString();
51     expect(component.getQueryString()).toEqual(component.queryString);
52   });
53
54   it('should test showError method', () => {
55       component.showError('test');
56       expect(component.errorMessage).toEqual('test'['errormessage']);
57       expect(component.stackTrace).toEqual('test'['stacktrace']);
58       expect(component.error).toEqual(true);
59       expect(component.showSpinner).toEqual(false);
60   });
61
62   it('should test showLabelFn method', () => {
63     component.showLabelFn();
64     expect(component.showLabel).toEqual(component.showLabel);
65   });
66
67   it('should test editReport method', () => {
68         component.editReport("test");
69   });
70
71    it('should test runReport method', () => {
72       component.iSDashboardReport = "test";
73       component.formFieldList.length = 1;
74        component.runReport();
75
76       expect(component.hitCnt).toBe(component.hitCnt++);
77       expect(component.reportMode).toBe("FormField");
78       let spy = spyOn(component, 'generateQueryString');
79       component.generateQueryString();
80       expect(component.generateQueryString).toHaveBeenCalled();
81       expect(component.showSpinner).toBe(false);
82
83       component.iSDashboardReport = "test";
84       component.formFieldList.length = 0;
85        component.runReport();
86
87        expect(component.reportMode).toBe("Regular");
88
89        component.iSDashboardReport = "Dashboard";
90        component.runReport();
91        expect(component.showSpinner).toBe(false);
92        expect(component.navigateToRun).toBe(true);
93
94
95    });
96
97    it('should test ngDoCheck method', () =>{
98         component.formFieldList != undefined;
99         component.oldGroupSelectValue = "test";
100         component.groupSelectValue = "testing";
101         component.ngDoCheck();
102
103         expect(component.oldGroupSelectValue).toBe(component.groupSelectValue);
104    });
105
106    it('should test fetchAndPopulateFormFields method', () => {
107         component.fetchAndPopulateFormFields(1, "test");
108    })
109
110    it('should test generateQueryString method',() => {
111       component.generateQueryString();
112    })
113 });