set default values in VFM Upgrade popup
[vid.git] / vid-webpack-master / src / app / shared / components / genericForm / formControlsServices / sharedControlles / shared.controllers.service.spec.ts
index 58ee33b..b141a1e 100644 (file)
@@ -9,7 +9,7 @@ import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flag
 import {DropdownFormControl} from "../../../../models/formControlModels/dropdownFormControl.model";
 import {FormControlModel, ValidatorOptions} from "../../../../models/formControlModels/formControl.model";
 import {ControlGeneratorUtil} from "../control.generator.util.service";
-
+import each from "jest-each";
 
 
 describe('Shared Controllers Service', () => {
@@ -100,11 +100,19 @@ describe('Shared Controllers Service', () => {
     expect(lcpRegionControl.isDisabled).toBeFalsy();
   });
 
-  test('sdn-preload checkbox is visible', () => {
-    const instance = {};
-    const sdncPreload: FormControlModel = service.getSDNCControl(instance);
+  each(
+    [
+      [' checked', true, true],
+      [' not checked', false, false ]
+    ]
+  ).
+  test('sdn-preload checkbox is %s', (
+    description: string, checkedByDefault: boolean, expected: boolean
+  ) => {
+    const instance = null;
+    const sdncPreload: FormControlModel = service.getSDNCControl(instance, checkedByDefault);
     expect (sdncPreload.displayName).toEqual('SDN-C pre-load');
-    expect (sdncPreload.value).toBeFalsy();
+    expect (sdncPreload.value).toBe(expected);
   });
 
   test('getlegacyRegion with AAIAIC25 - isVisible true', () => {
@@ -118,6 +126,18 @@ describe('Shared Controllers Service', () => {
     const legacyRegionControl: FormControlModel = service.getLegacyRegion(instance);
     expect(legacyRegionControl.isVisible).toBeFalsy();
   });
+
+  test('multiSelectFlag is not activated should generate platform multi select control with 1 as limitSelection', ()=>{
+    const control = service.getPlatformMultiselectControl(null, [],false);
+    expect(control.dataTestId).toEqual('multi-selectPlatform');
+    expect(control.limitSelection).toEqual(1);
+  });
+
+  test('multiSelectFlag is activated should generate platform multi select control with 1000 as limitSelection', ()=>{
+    const control = service.getPlatformMultiselectControl(null, [],true);
+    expect(control.dataTestId).toEqual('multi-selectPlatform');
+    expect(control.limitSelection).toEqual(1000);
+  });
 });
 
 class MockAppStore<T> {