diff options
author | 2019-12-17 09:33:35 +0000 | |
---|---|---|
committer | 2019-12-17 09:33:35 +0000 | |
commit | 5e3debb8feabc8bf0631344bacfff837629240e4 (patch) | |
tree | 61362b7c5719e3c9d51b0cde5604b4b629b94f71 /vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts | |
parent | 5f8ce4adff724009dad903887cd320a0095c1437 (diff) | |
parent | 8d17bc384337849ffdf4a8369834c4480c9c5d93 (diff) |
Merge "Do not show retain VGs checkbox in VFM Upgrade modal + tests modifications"
Diffstat (limited to 'vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts')
-rw-r--r-- | vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts index 7c1cc084a..4003b4dcc 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts @@ -1,6 +1,10 @@ import {LogService} from "../../../../utils/log/log.service"; import {NgRedux} from "@angular-redux/store"; -import {BasicControlGenerator, SDN_C_PRE_LOAD, SUPPLEMENTARY_FILE} from "../../../genericForm/formControlsServices/basic.control.generator"; +import { + BasicControlGenerator, + SDN_C_PRE_LOAD, + SUPPLEMENTARY_FILE +} from "../../../genericForm/formControlsServices/basic.control.generator"; import {AaiService} from "../../../../services/aaiService/aai.service"; import {HttpClient} from "@angular/common/http"; import {GenericFormService} from "../../../genericForm/generic-form.service"; @@ -20,6 +24,7 @@ import {GeneralActions} from "../../../../storeUtil/utils/general/general.action import {VfModuleActions} from "../../../../storeUtil/utils/vfModule/vfModule.actions"; import {ServiceActions} from "../../../../storeUtil/utils/service/service.actions"; import {FormControlModel} from "../../../../models/formControlModels/formControl.model"; +import * as _ from "lodash"; class MockModalService<T> {} @@ -29,6 +34,15 @@ class MockReduxStore<T> { getState() { return { service: { + serviceHierarchy: { + serviceId: { + vfModules: { + vfModuleName: { + volumeGroupAllowed: true + } + } + } + }, serviceInstance : { serviceId : { vnfs : { @@ -40,7 +54,6 @@ class MockReduxStore<T> { }}}}}}}} }; } - dispatch() {} } @@ -101,19 +114,31 @@ describe('VFModule popup service', () => { }); } - function getControlByNameAndCheckValue(controlName: string, expectedValue: any) { + function getControlByNameAndCheckValue(controlName: string, expectedValue: any, shouldControllerExist: boolean) { const controls = service.getControls('serviceId', 'vnfStoreKey', 'vfModuleId', true); const control = findControlByName(controls, controlName); - expect(control).toBeDefined(); - expect(control.value).toEqual(expectedValue); + if(shouldControllerExist){ + expect(control).toBeDefined(); + expect(control.value).toEqual(expectedValue); + } + else{ + expect(control).toBeUndefined(); + } } test('get controls should return retainAssignments control with true value', ()=> { - getControlByNameAndCheckValue(UpgradeFormControlNames.RETAIN_ASSIGNMENTS, true); + getControlByNameAndCheckValue(UpgradeFormControlNames.RETAIN_ASSIGNMENTS, true, true); }); test('get controls should return retainVolumeGroup control with true value', ()=> { - getControlByNameAndCheckValue(UpgradeFormControlNames.RETAIN_VOLUME_GROUPS, true); + getControlByNameAndCheckValue(UpgradeFormControlNames.RETAIN_VOLUME_GROUPS, true, true); + }); + + test('get controls should NOT return retainVolumeGroup control with true value', ()=> { + let stateCopy =_.cloneDeep(store.getState()); + stateCopy.service.serviceHierarchy['serviceId'].vfModules['vfModuleName'].volumeGroupAllowed = false; + jest.spyOn(store, 'getState').mockReturnValue(stateCopy); + getControlByNameAndCheckValue(UpgradeFormControlNames.RETAIN_VOLUME_GROUPS, null, false); }); test('get controls should contain SUPPLEMENTARY_FILE controller', ()=> { @@ -196,6 +221,6 @@ describe('VFModule popup service', () => { test( 'get controls should return usePreload with false value', () => { - getControlByNameAndCheckValue(SDN_C_PRE_LOAD, false); + getControlByNameAndCheckValue(SDN_C_PRE_LOAD, false, true); }); }); |