let service: SharedTreeService;
let _objectToInstanceTreeService: ObjectToInstanceTreeService;
let store: NgRedux<AppState>;
+
beforeAll(done => (async () => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule, NgReduxTestingModule, SdcUiComponentsModule],
expect(isDiffCustomizationUuidResponse).toEqual(expected);
});
+ each([
+ [false, true, true, false],
+ [true, true, true, true],
+ [true, true, false, true],
+ [true, false, true, true],
+ [true, false, false, false],
+ ]).
+ test('when flag is %s the UpdatedLatestVersion is %s and Vfmodule CustomizationUuid Differ is %s isShouldShowButtonGenericMustToBeCalled should return %s', (
+ flag: boolean,
+ isThereAnUpdatedLatestVersion: boolean,
+ isVfmoduleAlmostPartOfModelOnlyCustomizationUuidDiffer: boolean,
+ isShouldShowButtonGenericMustToBeCalled: boolean
+ ) => {
+ let node = <any> {};
+ let serviceModelId : string = '08c5fa17-769a-4231-bd92-aed4b0ed086d';
+ jest.spyOn(store, 'getState').mockReturnValue(<any>{
+ global: {
+ "flags": {
+ "FLAG_FLASH_REPLACE_VF_MODULE": flag,
+ },
+ }
+ });
+ spyOn(service, 'isThereAnUpdatedLatestVersion').and.returnValue(isThereAnUpdatedLatestVersion);
+ spyOn(service, 'isVfmoduleAlmostPartOfModelOnlyCustomizationUuidDiffer').and.returnValue(isVfmoduleAlmostPartOfModelOnlyCustomizationUuidDiffer);
+
+ expect(service.isVfMoudleCouldBeUpgraded(node, serviceModelId)).toEqual(isShouldShowButtonGenericMustToBeCalled);
+ });
+
});
function getStore() {
* should return true if customer can upgrade a VFM *
****************************************************/
shouldShowUpgrade(node, serviceModelId): boolean {
- if (FeatureFlagsService.getFlagState(Features.FLAG_FLASH_REPLACE_VF_MODULE, this._store) &&
- (this.isThereAnUpdatedLatestVersion(serviceModelId)) || this.isVfmoduleAlmostPartOfModelOnlyCustomizationUuidDiffer(node, serviceModelId)) {
- return this.shouldShowButtonGeneric(node, VNFMethods.UPGRADE, serviceModelId);
- }
- else {
- return false
+ return (this.isVfMoudleCouldBeUpgraded(node, serviceModelId))
+ && this.shouldShowButtonGeneric(node, VNFMethods.UPGRADE, serviceModelId) ;
}
+
+ isVfMoudleCouldBeUpgraded(node, serviceModelId): boolean{
+ return (FeatureFlagsService.getFlagState(Features.FLAG_FLASH_REPLACE_VF_MODULE, this._store) &&
+ ((this.isThereAnUpdatedLatestVersion(serviceModelId)) || this.isVfmoduleAlmostPartOfModelOnlyCustomizationUuidDiffer(node, serviceModelId)))
}