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