diff options
author | andre.schmid <andre.schmid@est.tech> | 2021-05-05 15:31:04 +0100 |
---|---|---|
committer | Christophe Closset <christophe.closset@intl.att.com> | 2021-05-15 06:21:13 +0000 |
commit | 2152a9a43767cdd486fd8c93894f66a05083f53c (patch) | |
tree | cbb64fc5680ba724bc317e27f6a20802d5b38502 /catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.spec.ts | |
parent | e3de4c9d214983d38a7d66e89dae5d4bba170ca3 (diff) |
Support for selection of capabilities
Change-Id: Ib1a3e3e1a59fc84c62620932c408e231acf77024
Issue-ID: SDC-3580
Signed-off-by: André Schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.spec.ts')
-rw-r--r-- | catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.spec.ts | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.spec.ts b/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.spec.ts new file mode 100644 index 0000000000..4de556cdd5 --- /dev/null +++ b/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.spec.ts @@ -0,0 +1,80 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +import {TestBed} from '@angular/core/testing'; +import {ISdcConfig, SdcConfigToken} from "../../config/sdc-config.config"; +import {ComponentInstanceServiceNg2} from "./component-instance.service"; +import {Capability} from "../../../models/capability"; +import {HttpClientTestingModule, HttpTestingController} from "@angular/common/http/testing"; + +describe('ComponentInstanceServiceNg2', () => { + let httpTestingController: HttpTestingController; + let componentInstanceService: ComponentInstanceServiceNg2; + let rootApi: string = 'http://localhost/' + let componentApiRoot: string = 'catalog/' + beforeEach(() => { + const sdcConfigToken: Partial<ISdcConfig> = { + 'api': { + 'root': rootApi, + 'component_api_root': componentApiRoot, + } + }; + TestBed.configureTestingModule({ + providers: [ComponentInstanceServiceNg2, + {provide: SdcConfigToken, useValue: sdcConfigToken} + ], + imports: [HttpClientTestingModule] + }); + httpTestingController = TestBed.get(HttpTestingController); + componentInstanceService = TestBed.get(ComponentInstanceServiceNg2); + }); + + it('should be created', () => { + expect(componentInstanceService).toBeTruthy(); + }); + + it('updateInstanceCapability call should return the expected data', () => { + const capabilityToUpdate = new Capability(); + capabilityToUpdate.type = "tosca.capabilities.Scalable"; + capabilityToUpdate.name = "capScalable"; + capabilityToUpdate.ownerId = "191f8a83-d362-4db4-af30-75d71a55c959.a822dd1c-3560-47ea-b8a2-f557fed5e186.vfcapreq10"; + capabilityToUpdate.uniqueId = "2047eb3c-de31-4413-a358-8710a3dd2670"; + capabilityToUpdate.external = true; + + const componentTypeUrl = "services/"; + let actualCapability: Capability; + componentInstanceService.updateInstanceCapability(componentTypeUrl, "componentId", "componentInstanceId", capabilityToUpdate) + .subscribe(capability => { + actualCapability = capability; + }); + + const request = + httpTestingController.expectOne(`${rootApi}${componentApiRoot}${componentTypeUrl}componentId/componentInstances/componentInstanceId/capability/`); + + expect(request.request.method).toEqual('PUT'); + + request.flush(capabilityToUpdate); + expect(actualCapability.name).toEqual(capabilityToUpdate.name); + expect(actualCapability.type).toEqual(capabilityToUpdate.type); + expect(actualCapability.ownerId).toEqual(capabilityToUpdate.ownerId); + expect(actualCapability.uniqueId).toEqual(capabilityToUpdate.uniqueId); + expect(actualCapability.external).toEqual(capabilityToUpdate.external); + }); + +}); |