diff options
author | Indrijeet kumar <indriku1@in.ibm.com> | 2020-04-28 14:33:07 +0530 |
---|---|---|
committer | Indrijeet Kumar <indriku1@in.ibm.com> | 2020-04-28 14:06:22 +0000 |
commit | 47846ad116e084f67a586592ecf0c466ae034937 (patch) | |
tree | 99b5e7af48a4a20cf1c4f6274e55aae5bdf64eec /ecomp-sdk/epsdk-app-overlay/src/main | |
parent | db6c63ebfcce75b364ac46fbf66d800aab2fa652 (diff) |
some test cases in form fields components
some test cases in form fields components
Issue-ID: PORTAL-813
Change-Id: I4dca2d33346ff4ebbdf921a2785cc65e11613619
Signed-off-by: Indrijeet Kumar <indriku1@in.ibm.com>
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src/main')
-rw-r--r-- | ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.spec.ts | 54 |
1 files changed, 27 insertions, 27 deletions
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(); +}) + }) |