summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-overlay
diff options
context:
space:
mode:
authorLorraine Welch <lb2391@att.com>2020-04-29 10:52:59 +0000
committerGerrit Code Review <gerrit@onap.org>2020-04-29 10:52:59 +0000
commitd4e9fbf93c206c61c25e9e20b23c65bda335f87b (patch)
tree2183473574c34e39867687c0000e63935182a15c /ecomp-sdk/epsdk-app-overlay
parent30df76c9c99eea33950d96256fae80fa80a071a7 (diff)
parent47846ad116e084f67a586592ecf0c466ae034937 (diff)
Merge "some test cases in form fields components"
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay')
-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.ts54
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();
+})
+
})