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';
9 describe('RunReportFormFieldsComponent', () => {
10 let component: RunReportFormFieldsComponent;
11 let fixture: ComponentFixture<RunReportFormFieldsComponent>;
12 let formfield =[{"validationType":1},{},{}] ;
14 beforeEach(async(() => {
15 TestBed.configureTestingModule({
16 schemas: [CUSTOM_ELEMENTS_SCHEMA],
17 imports: [FormsModule, MatDatepickerModule, HttpClientTestingModule, RouterTestingModule],
18 declarations: [ RunReportFormFieldsComponent ]
24 fixture = TestBed.createComponent(RunReportFormFieldsComponent);
25 component = fixture.componentInstance;
26 component.formFieldList = formfield;
27 fixture.detectChanges();
30 it('should create', () => {
31 expect(component).toBeTruthy();
34 it('should test ngOnInit method', () => {
36 // expect(component.showSpinner).toEqual(true);
37 // expect(component.navigateToRun).toEqual(false);
40 it('should test convertDate method', () => {
41 component.convertDate("test");
44 it('should test getQueryString methods', () => {
45 component.directCallQueryParams = 'abc';
46 component.getQueryString();
47 expect(component.getQueryString()).toEqual(component.directCallQueryParams);
49 component.directCallQueryParams = "";
50 component.getQueryString();
51 expect(component.getQueryString()).toEqual(component.queryString);
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);
62 it('should test showLabelFn method', () => {
63 component.showLabelFn();
64 expect(component.showLabel).toEqual(component.showLabel);
67 it('should test editReport method', () => {
68 component.editReport("test");
71 it('should test runReport method', () => {
72 component.iSDashboardReport = "test";
73 component.formFieldList.length = 1;
74 component.runReport();
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);
83 component.iSDashboardReport = "test";
84 component.formFieldList.length = 0;
85 component.runReport();
87 expect(component.reportMode).toBe("Regular");
89 component.iSDashboardReport = "Dashboard";
90 component.runReport();
91 expect(component.showSpinner).toBe(false);
92 expect(component.navigateToRun).toBe(true);
97 it('should test ngDoCheck method', () =>{
98 component.formFieldList != undefined;
99 component.oldGroupSelectValue = "test";
100 component.groupSelectValue = "testing";
101 component.ngDoCheck();
103 expect(component.oldGroupSelectValue).toBe(component.groupSelectValue);
106 it('should test fetchAndPopulateFormFields method', () => {
107 component.fetchAndPopulateFormFields(1, "test");
110 it('should test generateQueryString method',() => {
111 component.generateQueryString();