diff options
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src/main')
12 files changed, 184 insertions, 119 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.spec.ts index 1253b2be..bd9bea48 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.spec.ts @@ -91,12 +91,6 @@ describe('HeaderComponent', () => { expect(component).toBeTruthy(); }); - it('testing if condition in ngOnInit method',()=>{ - component.cookieService.set('show_app_header','false'); - component.ngOnInit(); - expect(component.showHeader).toBe(false) - }) - describe('should test ngOnInit',()=>{ it('should validate on ngOnInit',()=>{ let spy=spyOn(headerService, 'getTopMenuItems').and.returnValue(Observable.of('you object')); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/sidebar/sidebar.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/sidebar/sidebar.component.spec.ts index 42c176bf..9bbcfc4e 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/sidebar/sidebar.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/sidebar/sidebar.component.spec.ts @@ -90,13 +90,6 @@ describe('SidebarComponent', () => { expect(component).toBeTruthy(); }); - it('testing if condition in ngOnInit method',()=>{ - component.cookieService.set('show_app_header','false'); - component.ngOnInit(); - expect(component.showHeader).toBe(false) - }) - - describe('should test ngOnInit',()=>{ it('should validate on ngOnInit',()=>{ let spy=spyOn(sidebarService,'getLeftMenu').and.returnValue(Observable.of(stubData1)); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/layout.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/layout.component.spec.ts index 975f72c3..4bc9f5dc 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/layout.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/layout.component.spec.ts @@ -78,12 +78,6 @@ describe('LayoutComponent', () => { expect(component).toBeTruthy(); }); - it('testing if condition in ngOnInit method',()=>{ - component.cookieService.set('show_app_header','false'); - component.ngOnInit(); - expect(component.showHeader).toBe(false) - }) - it('should test receiveCollapsed method',()=>{ component.receiveCollapsed(true); expect(component.collapedSideBar).toBe(true); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.service.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.service.spec.ts index 8d5c6637..e2b4c720 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.service.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.service.spec.ts @@ -69,10 +69,6 @@ describe('MenusService', () => { expect(component).toBeTruthy(); }); - // it('should test getTotalRowCount method',()=>{ - // component.getTotalRowCount(); - // }) - it('should test updateStatus method',()=>{ component['updateStatus']('N'); }) diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/roles.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/roles.component.spec.ts index 11daaf84..85f62164 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/roles.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/roles.component.spec.ts @@ -113,10 +113,6 @@ describe('RolesComponent', () => { expect(spy).toHaveBeenCalled(); }) - it('should test getRole method',()=>{ - component.getRole("value"); - }) - it('should test delRoleConfirmPopUp method',()=>{ component.delRoleConfirmPopUp('dummyargument'); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/columns/column.service.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/columns/column.service.spec.ts index 22e1cc3d..e663001a 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/columns/column.service.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/columns/column.service.spec.ts @@ -12,9 +12,6 @@ describe('ColumnService', () => { imports: [HttpClientTestingModule] })); - // httpClient=TestBed.get(HttpClient); - // httpTestingController=TestBed.get(httpTestingController); - it('should be created', () => { const service: ColumnService = TestBed.get(ColumnService); expect(service).toBeTruthy(); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.spec.ts index d53e63ce..7cc85b94 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.spec.ts @@ -5,7 +5,6 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { MatDialogModule, MatSnackBarModule } from '@angular/material'; -import { CommonModule } from '@angular/common'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { FormFieldsService } from './form-fields.service'; import 'rxjs/add/observable/of'; @@ -18,12 +17,10 @@ describe('FormFieldsComponent', () => { let _formfieldservice: FormFieldsService; var responseFormFields=[{"orderSeq":3}]; var formFieldGroupsJSON={"formFieldGroupsJSON":'{"data":"cachedRegions"}'}; - var formFieldsListObj=[{"formFieldsListObj":[ {"id":1}]}]; var responseDeleted={"responseDeleted":[{"message":"Formfield Deleted"}]} var responseDefaultSQL={"data":[{"elemensts":"indrijeet"}]}; var responsePost={"message":true}; var stubData=[{m:true}]; - var stubData1=[{n:{"id":1}}] beforeEach(async(() => { TestBed.configureTestingModule({ @@ -59,26 +56,17 @@ describe('FormFieldsComponent', () => { expect(component).toBeTruthy(); }); - //The blow test case is wrong. - // it('should test moveUpward method',()=>{ - // component.formFieldsListObj[n]["id"]=1; - // let spy=spyOn(_formfieldservice,'getFormFieldData').and.returnValue(Observable.of(stubData1)) - // component.moveUpward(1); - // component.formFieldsListObj[n]["id"]=1; - // }) - it('should test verify method',()=>{ - let spy=spyOn(_formfieldservice,'verifySQL').and.returnValue(Observable.of(responseDefaultSQL)) + spyOn(_formfieldservice,'verifySQL').and.returnValue(Observable.of(responseDefaultSQL)) component.verify("Default"); expect(component.validateResponseString).toEqual( responseDefaultSQL["data"]["elements"]) - component.verify("value"); - + component.verify("value"); }) it('should test ngOnInit method',()=>{ let spy=spyOn(_formfieldservice,'getListOfFormFields').and.returnValue(Observable.of(responseFormFields)) - let spy1=spyOn(_formfieldservice,'getFormFieldGroupsData').and.returnValue(Observable.of(formFieldGroupsJSON)) + spyOn(_formfieldservice,'getFormFieldGroupsData').and.returnValue(Observable.of(formFieldGroupsJSON)) component.ngOnInit(); expect(spy).toHaveBeenCalled(); }) @@ -174,12 +162,13 @@ describe('FormFieldsComponent', () => { it('should test addToList method',()=>{ component.addToList("attrib") - { + { expect(component.predefinedValueList.pop()).toEqual({id:'attrib', name:'attrib',selected:false}); } }); it('should test deleteFromList method',()=>{ +component.predefinedValueList=[{"id":"attrib"}] component.deleteFromList("attrib"); }); @@ -189,11 +178,11 @@ it('should test save method1',()=>{ component.defaultValue=false; component.mode ="Edit"; responseFormFields["m"]=1; - spyOn(_formfieldservice,'postFormFieldData').and.returnValue(Observable.of(responsePost)); - spyOn(_formfieldservice,'getListOfFormFields').and.returnValue(Observable.of(stubData)); + let spy1=spyOn(_formfieldservice,'postFormFieldData').and.returnValue(Observable.of(responsePost)); + let spy2=spyOn(_formfieldservice,'getListOfFormFields').and.returnValue(Observable.of(stubData)); component.save(); - // expect(component.showSpinner).toBe(true); - // expect(component.showDialog).toBe(false); + expect(spy1).toHaveBeenCalled(); + expect(spy2).toHaveBeenCalled(); expect(component.finalPOSTObj["validationType"]).toEqual(component.validationType); expect(component.finalPOSTObj["visible"]).toBe(true); expect(component.finalPOSTObj["orderSeq"]).toEqual(component.orderSeq); @@ -216,9 +205,11 @@ it('should test save method for else part',()=>{ component.defaultValue!=false; component.mode ="Edited"; responseFormFields["m"]=1; - spyOn(_formfieldservice,'addFormFieldData').and.returnValue(Observable.of(responsePost)); - spyOn(_formfieldservice,'getListOfFormFields').and.returnValue(Observable.of(stubData)); + let spy1=spyOn(_formfieldservice,'addFormFieldData').and.returnValue(Observable.of(responsePost)); + let spy2=spyOn(_formfieldservice,'getListOfFormFields').and.returnValue(Observable.of(stubData)); component.save(); + expect(spy1).toHaveBeenCalled(); + expect(spy2).toHaveBeenCalled(); expect(component.finalPOSTObj["visible"]).toBe(false) expect(component.finalPOSTObj["fieldDefalultSQL"]).toEqual(component.fieldDefaultSQL); }) @@ -232,24 +223,33 @@ it('should test openSnackBar method',()=>{ }) it('should test deleteGroup method',()=>{ - component.deleteGroup("string"); + component.Groups=[{"name":"groupName"}]; + component.deleteGroup("groupName"); }) it('should test deleteFormGroup method',()=>{ + component.Groups=[{"formFieldList":{"id":"formFieldId"}}] + //component.Groups=[{"elements":{"formFieldList":{"id":"formFieldId"}}}] component.deleteFromGroup("formgroup"); }) it('should test delete method',()=>{ responseDeleted["message"]="Formfield Deleted"; - let spy=spyOn(_formfieldservice,'deleteFormField').and.returnValue(Observable.of(responseDeleted)); - spyOn(_formfieldservice,'getListOfFormFields').and.returnValue(Observable.of('you object')) + let spy1=spyOn(_formfieldservice,'deleteFormField').and.returnValue(Observable.of(responseDeleted)); + let spy2=spyOn(_formfieldservice,'getListOfFormFields').and.returnValue(Observable.of('you object')) component.delete("delete"); + expect(spy1).toHaveBeenCalled(); + expect(spy2).toHaveBeenCalled(); }) - - it('should test createGroup method',()=>{ component.openDialog() }) +it('should test createGroup method',()=>{ + let spy=spyOn(component,'openDialog'); + component.createGroup(); + expect(spy).toHaveBeenCalled(); +}) + }) diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/log/log.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/log/log.component.spec.ts index e2b08a4f..af8e9db7 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/log/log.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/log/log.component.spec.ts @@ -16,13 +16,7 @@ describe('LogComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ LogComponent ], - imports: [HttpClientTestingModule], - // providers:[LogService,MockBackend,BaseRequestOptions,{ - // porvide:Http,useFactory:(backend:MockBackend,defaultOptions:BaseRequestOptions)=>{ - // return new Http(backend,defaultOptions); - // }, - // deps:[MockBackend,BaseRequestOptions], - // }] + imports: [HttpClientTestingModule] }) .compileComponents(); })); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.spec.ts index a1906c85..0e1d326d 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.spec.ts @@ -1,41 +1,49 @@ 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 { CUSTOM_ELEMENTS_SCHEMA} 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 { of } from 'rxjs'; +import { ActivatedRoute } from '@angular/router'; describe('RunReportFormFieldsComponent', () => { let component: RunReportFormFieldsComponent; let fixture: ComponentFixture<RunReportFormFieldsComponent>; let formfield =[{"validationType":1},{},{}] ; let runService: RunService; + let activatedRoute:ActivatedRoute; let environment = [ { baseUrl: 'just for testing' } - ] + ]; + var responseDefPage={ + "reportName":"reportName", + "reportType":"reportType", + } + + var responseFormFieldGroups={"formFieldGroupsJSON":'{"Indrijeet":"kumar"}'}; + var respObj={"formFieldList":{"value1":"value1"}}; beforeEach(async(() => { TestBed.configureTestingModule({ schemas: [CUSTOM_ELEMENTS_SCHEMA], - imports: [FormsModule, MatDatepickerModule, HttpClientTestingModule, RouterTestingModule], + imports: [ + FormsModule, + MatDatepickerModule, + HttpClientTestingModule, + RouterTestingModule + ], declarations: [ RunReportFormFieldsComponent ], providers: [RunService] }) .compileComponents(); runService = TestBed.get(RunService); - // spyOn(runService, 'getReportData').and.returnValue(Observable.of(environment)); - // spyOn(runService, 'getReportDataWithFormFields').and.returnValue(Observable.of(environment)); - spyOn(runService, 'getDefinitionPageDetails').and.returnValue(Observable.of(environment)); - spyOn(runService, 'refreshFormFields').and.returnValue(Observable.of(environment)); - // spyOn(runService, 'downloadReportExcel').and.returnValue(Observable.of(environment)); - spyOn(runService, 'getFormFieldGroupsData').and.returnValue(Observable.of(environment)); + spyOn(runService, 'refreshFormFields').and.returnValue(Observable.of(environment)); })); beforeEach(() => { @@ -43,12 +51,76 @@ describe('RunReportFormFieldsComponent', () => { component = fixture.componentInstance; component.formFieldList = formfield; fixture.detectChanges(); + activatedRoute=TestBed.get(ActivatedRoute); }); it('should create', () => { expect(component).toBeTruthy(); }); + describe('should test subscribe method in ngOnInit method',()=>{ + it('should test first if condition inside the subscribe',()=>{ + component.reportId="reportId"; + component.calledWithFormFields=false; + var response={"errormessage":true}; + spyOn(runService,'getDefinitionPageDetails').and.returnValue(Observable.of(responseDefPage)); + spyOn(runService,'getReportData').and.returnValue(Observable.of(response)); + component.ngOnInit(); + }) + + it('should test first if inside first if condition inside the subscribe',()=>{ + component.reportId="reportId"; + component.calledWithFormFields=false; + var response={"errormessage":false, + "reportName":"reportName", + "formFieldList":"formFieldList" + } + spyOn(runService,'getDefinitionPageDetails').and.returnValue(Observable.of(responseDefPage)); + spyOn(runService,'getReportData').and.returnValue(Observable.of(response)); + component.ngOnInit(); + }) + + it('should test else part line 101',()=>{ + component.reportId="reportId"; + component.calledWithFormFields=false; + var response={"errormessage":false,"reportName":"reportName","formFieldList":""} + spyOn(runService,'getDefinitionPageDetails').and.returnValue(Observable.of(responseDefPage)); + spyOn(runService,'getReportData').and.returnValue(Observable.of(response)); + component.ngOnInit(); + }) + + it('should test the else part line 111',()=>{ + component.reportId="reportId"; + component.calledWithFormFields=true; + spyOn(runService,'getDefinitionPageDetails').and.returnValue(Observable.of(responseDefPage)); + component.ngOnInit(); + }) + + describe('should test the else part under subscribe in ngOnInit method',()=>{ + + it('should test the else part 142',()=>{ + component.reportId="reportId"; + var response={"errormessage":false,"formFieldList":"formFieldList"}; + var responseDefPage={ + "reportName":"reportName", + "reportType":"Dashboard", + "dashboardLayoutJSON":'{"data":"dat"}', + "formFieldList":"" + }; + spyOn(runService,'getDefinitionPageDetails').and.returnValue(Observable.of(responseDefPage)); + spyOn(runService,'getReportData').and.returnValue(Observable.of(response)); + component.ngOnInit(); + }) +}) + +}) + + it('should test ngOnInit method', () => { + spyOn(component, 'ngOnInit').and.callThrough(); + component.ngOnInit(); + expect(component.ngOnInit).toHaveBeenCalled(); + }); + it('should test convertDate method', () => { component.convertDate("test"); }); @@ -121,17 +193,11 @@ describe('RunReportFormFieldsComponent', () => { component.generateQueryString(); }) - it('should test ngOnInit method', () => { - spyOn(component, 'ngOnInit').and.callThrough(); - component.ngOnInit(); - expect(component.ngOnInit).toHaveBeenCalled(); - }); -// it('should test fetchAndPopulateFormFields method', () => { -// spyOn(component, 'fetchAndPopulateFormFields').and.callThrough(); -// component.formFieldGroupObjList = null; -// component.fetchAndPopulateFormFields(1, "test"); -// expect(component.fetchAndPopulateFormFields).toHaveBeenCalled(); -// }); + it('should test fetchAndPopulateFormFields method', () => { + component.formFieldGroupObjList=[{"formFieldList":"formFieldList"}] + spyOn(runService, 'getFormFieldGroupsData').and.returnValue(Observable.of(responseFormFieldGroups)); + component.fetchAndPopulateFormFields(respObj,"value2"); + }); });
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-result-set/run-report-result-set.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-result-set/run-report-result-set.component.spec.ts index 44765d49..fa856c00 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-result-set/run-report-result-set.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-result-set/run-report-result-set.component.spec.ts @@ -6,12 +6,21 @@ import { MatTableModule } from '@angular/material/table'; import { RunReportResultSetComponent } from './run-report-result-set.component'; import { HttpClientTestingModule } from '@angular/common/http/testing'; -import { HttpClient } from '@angular/common/http'; import { RouterTestingModule } from '@angular/router/testing'; +import { RunService } from '../run.service'; +import 'rxjs/add/observable/of'; +import { Observable } from 'rxjs/Observable'; +import 'rxjs/add/operator/catch'; +import 'rxjs/add/observable/throw'; describe('RunReportResultSetComponent', () => { let component: RunReportResultSetComponent; let fixture: ComponentFixture<RunReportResultSetComponent>; + let _runService:RunService; + var response={ + "reportDataColumns":[{"columnTitle":"columnTitle"}], + "reportDataRows":[{"colId":"colId"}] + } beforeEach(async(() => { TestBed.configureTestingModule({ @@ -31,9 +40,26 @@ describe('RunReportResultSetComponent', () => { fixture = TestBed.createComponent(RunReportResultSetComponent); component = fixture.componentInstance; fixture.detectChanges(); + _runService=TestBed.get(RunService); }); it('should compile', () => { expect(component).toBeTruthy(); }); + + it('should test ngOnInit method',()=>{ + component.reportId1="reportId1"; + let spy=spyOn(_runService,'getReportData').and.returnValue(Observable.of(response)); + component.ngOnInit(); + expect(spy).toHaveBeenCalled(); + + }) + + it('should test ngAfterViewInit method',()=>{ + component.reportId1="reportId1"; + let spy=spyOn(_runService,'getReportData').and.returnValue(Observable.of(response)) + component.ngAfterViewInit(); + expect(spy).toHaveBeenCalled(); + }) + }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-report.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-report.component.spec.ts index a41b11cd..2aeac4a2 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-report.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-report.component.spec.ts @@ -2,10 +2,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { MatPaginatorModule } from '@angular/material/paginator'; import { MatSortModule } from '@angular/material/sort'; -import { MatTableModule, MatTableDataSource } from '@angular/material/table'; +import { MatTableModule} from '@angular/material/table'; -import { RunReportComponent, PeriodicElement } from './run-report.component'; -import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, SimpleChange, SimpleChanges } from '@angular/core'; +import { RunReportComponent} from './run-report.component'; +import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, SimpleChanges } from '@angular/core'; import { MatMenuModule } from '@angular/material'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { RouterTestingModule } from '@angular/router/testing'; @@ -24,13 +24,12 @@ describe('RunReportComponent', () => { let runService : RunService; let options1 = {}; let dashboard; - let dashboard2; let responseformfield = 1; let environment = [ { baseUrl: 'just a link' } - ] + ]; beforeEach(async(() => { @@ -49,13 +48,10 @@ describe('RunReportComponent', () => { providers: [RunService] }).compileComponents(); runService = TestBed.get(RunService); - //spyOn(runService, 'getReportDataWithFormFields').and.returnValue(Observable.of(environment)); - //spyOn(runService, 'getReportData').and.returnValue(Observable.of(environment)); spyOn(runService, 'downloadReportExcel').and.returnValue(Observable.of(environment)); })); beforeEach(() => { - //dashboard = {"item":{"hasContent":{"name":"rupi","id":"check#check"}}}; fixture = TestBed.createComponent(RunReportComponent); runService = TestBed.get(RunService); component = fixture.componentInstance; @@ -107,6 +103,7 @@ describe('RunReportComponent', () => { expect(component.NEWdisplayedColumns).toEqual(new Array()); }); + it('should test showError method', () => { let errmsg = "errormessage"; let stcktrace = "stacktrace"; @@ -148,40 +145,40 @@ describe('RunReportComponent', () => { it('should test the ngOnChanges first If condition', () => { change = {}; + component.queryString="queryString"; + component.reportId1="reportId1"; + var response={"errormessage":true} component.reportMode !== "Regular" component.initCnt = 1; component.TriggerFFArr.length = 0; + let spy=spyOn(runService,'getReportDataWithFormFields').and.returnValue(Observable.of(response)); component.ngOnChanges(change); - expect(component.showMoreVert).toEqual(false); + expect(spy).toHaveBeenCalled(); expect(component.initCnt).toEqual(1); expect(component.showDashboardReport).toEqual(false); expect(component.displayedRowObj).toEqual(new Array()); expect(component.displayedColumns).toEqual(new Array()); expect(component.formFieldList).toEqual(new Array()); - expect(component.showSpinner).toEqual(true); expect(component.NEWdisplayedColumns).toEqual(new Array()); expect(component.isReady).toEqual(false); + }); + it('should test initialProcess method', () => { component.DashboardReportObj.length = 1; component.initialProcesses(); }); - // it('should test postFetchingReportDataFn method', () => { - // let response: any; - // component.postFetchingReportDataFn(response); - // }) - - // it('should test ngOnChanges subscribe method', () => { - // spyOn(component, 'ngOnChanges').and.callThrough(); - // component.ngOnChanges(change); - // expect(component.ngOnChanges).toHaveBeenCalled(); + // it('should test postFetchingReportDataFn method',()=>{ + // var response={ + // "reportName":"reportName", + // "reportDataColumns":[{"columnTitle":"columnTitle","colId":"colId"}], + // "reportDataRows":[{"value":"value"}] + // } + // component.displayedColumnsArr=["string"] + // component.postFetchingReportDataFn(response) // }) - // it('should test postFetchingReportDataFn method', () => { - // let obj: any; - // component.postFetchingReportDataFn(obj); - // }) - + }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.component.spec.ts index 52082c9f..68085b1e 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.component.spec.ts @@ -16,7 +16,6 @@ describe('SQLComponentComponent', () => { let fixture: ComponentFixture<SQLComponent>; const reportId = "test"; const finalGetObj = {"query":"dummyQuery"}; - let elements = []; let environment = [ { "baseUrl": 'just for test' @@ -32,9 +31,7 @@ describe('SQLComponentComponent', () => { }) .compileComponents(); sqlService = TestBed.get(SqlService); - let response : any; spyOn(sqlService, 'getSQLTabData').and.returnValue(Observable.of(environment)); - spyOn(sqlService, 'postSQLValidateAndSave').and.returnValue(Observable.of(environment)); })); beforeEach(() => { @@ -82,6 +79,27 @@ describe('SQLComponentComponent', () => { expect(component.SQLclosable).toEqual(true); }); + it('should test saveSQL method else condition',()=>{ + component.SQLPostResponse = false; + component.saveSQL(); + }) + + it('should test validate method',()=>{ + component.sqlText="sqlText"; + var response={"data":{"elements":'{"elements":""}'}} + let spy=spyOn(sqlService,'postSQLValidateAndSave').and.returnValue(Observable.of(response)) + component.validate(); + expect(spy).toHaveBeenCalled(); + }) + + it('should test validate method',()=>{ + component.sqlText="sqlText"; + var response={"data":{"elements":'{"query":"query"}'}} + let spy=spyOn(sqlService,'postSQLValidateAndSave').and.returnValue(Observable.of(response)) + component.validate(); + expect(spy).toHaveBeenCalled(); + }) + it('should test closeSaveModal method', () => { component.closeSaveModal(); expect(component.showSaveSQLDialog).toEqual(component.showSaveSQLDialog); @@ -113,10 +131,4 @@ describe('SQLComponentComponent', () => { expect(component.GetValidateResponseString()).toEqual("test"); }); -// it('should test validate method', () => { -// spyOn(component, 'validate').and.callThrough(); -// component.validate(); -// expect(component.validate).toHaveBeenCalled(); -// }); - }); |