Merge "upgrade vfmodule when upgraded already service, vnf and brother vfmodule e2e"
[vid.git] / vid-webpack-master / src / app / shared / components / genericForm / formControlsServices / vnfGenerator / vnf.control.generator.spec.ts
index 5c6e25c..c7d6236 100644 (file)
@@ -2,7 +2,7 @@ import {getTestBed, TestBed} from '@angular/core/testing';
 import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
 import {NgRedux} from '@angular-redux/store';
 import {FormControlNames} from "../service.control.generator";
-import {BasicControlGenerator} from "../basic.control.generator";
+import {ControlGeneratorUtil} from "../control.generator.util.service";
 import {AaiService} from "../../../../services/aaiService/aai.service";
 import {GenericFormService} from "../../generic-form.service";
 import {FormBuilder} from "@angular/forms";
@@ -13,9 +13,9 @@ import {
 } from "../../../../models/formControlModels/formControl.model";
 import {LogService} from "../../../../utils/log/log.service";
 import {VnfControlGenerator} from "./vnf.control.generator";
-import {Observable} from "rxjs";
-import {SelectOption} from "../../../../models/selectOption";
 import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
+import {FormControlType} from "../../../../models/formControlModels/formControlTypes.enum";
+import {SharedControllersService} from "../sharedControlles/shared.controllers.service";
 
 class MockAppStore<T> {
   getState(){
@@ -28,7 +28,6 @@ class MockAppStore<T> {
           "FLAG_FABRIC_CONFIGURATION_ASSIGNMENTS": true,
           "FLAG_SHOW_VERIFY_SERVICE": false,
           "FLAG_SERVICE_MODEL_CACHE": true,
-          "FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD": false,
           "FLAG_ADD_MSO_TESTAPI_FIELD": true
         },
         "type": "[FLAGS] Update"
@@ -909,7 +908,9 @@ class MockAppStore<T> {
   }
 }
 
-class MockFeatureFlagsService {}
+class MockFeatureFlagsService {
+  getFlagState = () => false;
+}
 
 describe('VNF Control Generator', () => {
   let injector;
@@ -922,7 +923,8 @@ describe('VNF Control Generator', () => {
       imports: [HttpClientTestingModule],
       providers: [VnfControlGenerator,
         GenericFormService,
-        BasicControlGenerator,
+        ControlGeneratorUtil,
+        SharedControllersService,
         AaiService,
         FormBuilder,
         LogService,
@@ -939,6 +941,18 @@ describe('VNF Control Generator', () => {
   })().then(done).catch(done.fail));
 
 
+  test('should generate platform multi select control', ()=>{
+    const control = service.getPlatformMultiselectControl(null, [],false);
+    expect(control.type).toEqual(FormControlType.MULTI_SELECT);
+    expect(control.controlName).toEqual('platformName');
+    expect(control.displayName).toEqual('Platform');
+    expect(control.dataTestId).toEqual('multi-selectPlatform');
+    expect(control.selectedFieldName).toEqual('name');
+    expect(control.value).toEqual('');
+    expect(control.onChange).toBeDefined();
+    expect(control.convertOriginalDataToArray).toBeDefined();
+  });
+
   test('getMacroFormControls check for mandatory controls', () => {
     const serviceId : string = "6e59c5de-f052-46fa-aa7e-2fca9d674c44";
     const vnfName : string = "VF_vGeraldine 0";
@@ -949,7 +963,8 @@ describe('VNF Control Generator', () => {
       FormControlNames.INSTANCE_NAME,
       FormControlNames.LCPCLOUD_REGION_ID,
       FormControlNames.TENANT_ID,
-      'platformName'
+      'platformName',
+      FormControlNames.PRODUCT_FAMILY_ID
     ];
 
     for(let i = 0 ; i < mandatoryControls.length ; i++){
@@ -1045,15 +1060,5 @@ describe('VNF Control Generator', () => {
     const instanceNameValidator: ValidatorModel = instanceNameControl.validations.find(val => val.validatorName === ValidatorOptions.pattern);
     expect(instanceNameValidator.validatorArg).toEqual(/^[a-zA-Z0-9._-]*$/);
   });
-
-  test('rollback should return observable of true, false', () => {
-    let result : Observable<SelectOption[]> = service.getRollBackOnFailureOptions();
-    result.subscribe((val)=>{
-      expect(val).toEqual([
-        new SelectOption({id: 'true', name: 'Rollback'}),
-        new SelectOption({id: 'false', name: 'Don\'t Rollback'})
-      ]);
-    });
-  });
 });