summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLorraine Welch <lb2391@att.com>2020-03-05 15:51:21 +0000
committerGerrit Code Review <gerrit@onap.org>2020-03-05 15:51:21 +0000
commitf429b28cc7f5a26a8c6ebff43139841f2499018e (patch)
tree603c4d8ce721df67626a758cc3afd99b9dfe3a3a
parent0db1598e4430ed80b43d4fc00323630ea3c54d22 (diff)
parentf45d43f248be5b0ffaad703fa50901f943214502 (diff)
Merge "more test cases in form-fields component"
-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.ts84
1 files changed, 66 insertions, 18 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 8d9003fc..88010f96 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
@@ -7,10 +7,14 @@ 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';
+import { Observable } from 'rxjs/Observable';
describe('FormFieldsComponent', () => {
let component: FormFieldsComponent;
let fixture: ComponentFixture<FormFieldsComponent>;
+ let _formfieldservice: FormFieldsService;
beforeEach(async(() => {
TestBed.configureTestingModule({
@@ -21,7 +25,7 @@ describe('FormFieldsComponent', () => {
HttpClientTestingModule,
MatDialogModule,
MatSnackBarModule,
- // BrowserAnimationsModule
+ BrowserAnimationsModule
]
})
.compileComponents();
@@ -31,6 +35,7 @@ describe('FormFieldsComponent', () => {
fixture = TestBed.createComponent(FormFieldsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
+ _formfieldservice=TestBed.get(FormFieldsService);
});
it('should create', () => {
@@ -42,28 +47,37 @@ describe('FormFieldsComponent', () => {
expect(component.isFirst(2)).toBe(false);
});
- it('should test isLast method', () =>{
+ it('should test isLast method1 ', () =>{
component.formFieldsListObj.length = 12;
expect(component.isLast(15)).toEqual(false);
});
- it('should test ngDoCheck method',()=>{
+ it('should test isLast method2 ', () =>{
+ component.formFieldsListObj.length = 12;
+ expect(component.isLast(11)).toEqual(true);
+ });
+
+ it('should test ngDoCheck method for if condition',()=>{
component.sqlAsDefaultValue=true;
- if(component.sqlAsDefaultValue==true){
- expect(component.showDefaultSQLOption).toBe(false);
- }
- else{
- expect(component.showDefaultSQLOption).toBe(true);
- }
+ component.ngDoCheck();
+ expect(component.showDefaultSQLOption).toBe(true);
});
+ it('should test ngDoCheck method for else condition',()=>{
+ component.sqlAsDefaultValue!=true;
+ component.ngDoCheck();
+ expect(component.showDefaultSQLOption).toBe(false);
+});
+
it('should test setDisplayMode method',()=>{
component.setDisplayMode("setDisplayMode");
});
it('should test edit method',()=>{
+ component.fieldDefaultSQL!=null;
+ let spy=spyOn(_formfieldservice,'getFormFieldData').and.returnValue(Observable.of('you object'));
component.edit("Id");
-
+ expect(spy).toHaveBeenCalled();
})
it('should test add method',()=>{
@@ -127,15 +141,15 @@ it('should test deleteFromList method',()=>{
component.deleteFromList("attrib");
});
-it('should test save method',()=>{
+it('should test save method1',()=>{
+
+ component.visible="YES";
+ component.defaultValue=false;
component.save();
expect(component.showSpinner).toBe(true);
expect(component.showDialog).toBe(false);
expect(component.finalPOSTObj["validationType"]).toEqual(component.validationType);
- if(component.visible=="YES")
expect(component.finalPOSTObj["visible"]).toBe(true);
- else
- expect(component.finalPOSTObj["visible"]).toBe(false);
expect(component.finalPOSTObj["orderSeq"]).toEqual(component.orderSeq);
expect(component.finalPOSTObj["message"]).toEqual(component.message);
expect(component.finalPOSTObj["groupFormField"]).toEqual(component.groupFormField);
@@ -146,13 +160,47 @@ it('should test save method',()=>{
expect(component.finalPOSTObj["errorStackTrace"]).toEqual(component.errorStackTrace);
expect(component.finalPOSTObj["errorMessage"]).toEqual(component.errorMessage);
expect(component.finalPOSTObj["defaultValue"]).toEqual(component.defaultValue);
- if(component.defaultValue===false)
- expect(component.finalPOSTObj["fieldDefaultSQL"]).toBe(null);
- else
- expect(component.finalPOSTObj["fieldDefalultSQL"]).toEqual(component.fieldDefaultSQL);
+ expect(component.finalPOSTObj["fieldDefaultSQL"]).toBe(null);
expect(component.finalPOSTObj["predefinedValueList"]).toEqual(component.predefinedValueList);
});
+it('should test save method for else part',()=>{
+ component.visible!="YES";
+ component.defaultValue!=false;
+ component.save();
+ expect(component.finalPOSTObj["visible"]).toBe(false)
+ expect(component.finalPOSTObj["fieldDefalultSQL"]).toEqual(component.fieldDefaultSQL);
+})
+
+it('should test saveFormFieldGroups method',()=>{
+ component.saveFormFieldGroups();
+})
+
+it('should test openSnackBar method',()=>{
+ component.openSnackBar('message','action');
+})
+
+it('should test deleteGroup method',()=>{
+ component.deleteGroup("string");
+})
+
+it('should test deleteFormGroup method',()=>{
+ component.deleteFromGroup("formgroup");
+})
+
+it('should test delete method',()=>{
+ component.delete("delete");
+})
+
+it('should test verify method',()=>{
+component.verify("Default");
+component.verify("value");
+
+})
+
+// it('should test createGroup method',()=>{
+// component.openDialog()
+// })
});