From 101193d07d757ce299c34fc61ea37b416138bf85 Mon Sep 17 00:00:00 2001 From: sebdet Date: Thu, 5 Sep 2019 18:25:59 +0200 Subject: Draft of React test Reworking the react test with Jest & Enzyme + coverage Issue-ID: CLAMP-425 Change-Id: If287e357f4afaf712587e21ef5e0cb26f8a46d4c Signed-off-by: sebdet --- ui-react/src/__test__/LoopCache.test.js | 206 --------------------- .../src/__test__/LoopCache_mokeLoopJsonCache.json | 117 ------------ ui-react/src/__test__/OpenLoopModal.test.js | 35 ---- .../__snapshots__/OpenLoopModal.test.js.snap | 3 - ui-react/src/api/LoopCache.test.js | 205 ++++++++++++++++++++ ui-react/src/api/LoopCache_mokeLoopJsonCache.json | 117 ++++++++++++ .../dialogs/OpenLoop/OpenLoopModal.test.js | 45 +++++ .../__snapshots__/OpenLoopModal.test.js.snap | 92 +++++++++ ui-react/src/setupTests.js | 28 ++- 9 files changed, 485 insertions(+), 363 deletions(-) delete mode 100644 ui-react/src/__test__/LoopCache.test.js delete mode 100644 ui-react/src/__test__/LoopCache_mokeLoopJsonCache.json delete mode 100644 ui-react/src/__test__/OpenLoopModal.test.js delete mode 100644 ui-react/src/__test__/__snapshots__/OpenLoopModal.test.js.snap create mode 100644 ui-react/src/api/LoopCache.test.js create mode 100644 ui-react/src/api/LoopCache_mokeLoopJsonCache.json create mode 100644 ui-react/src/components/dialogs/OpenLoop/OpenLoopModal.test.js create mode 100644 ui-react/src/components/dialogs/OpenLoop/__snapshots__/OpenLoopModal.test.js.snap (limited to 'ui-react/src') diff --git a/ui-react/src/__test__/LoopCache.test.js b/ui-react/src/__test__/LoopCache.test.js deleted file mode 100644 index 1efea6495..000000000 --- a/ui-react/src/__test__/LoopCache.test.js +++ /dev/null @@ -1,206 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * 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. - * ============LICENSE_END============================================ - * =================================================================== - * - */ -import React from 'react'; -import LoopCache from '../api/LoopCache'; - -const json = require('./LoopCache_mokeLoopJsonCache.json'); - -describe('Verify LoopCache functions', () => { - const loopCache = new LoopCache(json); - it('getLoopName', () => { - expect(loopCache.getLoopName()).toBe("LOOP_Jbv1z_v1_0_ResourceInstanceName1_tca"); - }); - - it('getOperationalPolicyConfigurationJson', () => { - const opPolicyConfig = { - "guard_policies": {}, - "operational_policy": { - "controlLoop": {}, - "policies": [] - } - }; - expect(loopCache.getOperationalPolicyConfigurationJson()).toStrictEqual(opPolicyConfig); - }); - - it('getOperationalPolicies', () => { - const opPolicy = [{ - "name": "OPERATIONAL_h2NMX_v1_0_ResourceInstanceName1_tca", - "configurationsJson": { - "guard_policies": {}, - "operational_policy": { - "controlLoop": {}, - "policies": [] - - } - } - }]; - expect(loopCache.getOperationalPolicies()).toStrictEqual(opPolicy); - }); - - it('getGlobalProperties', () => { - const globelProp = { - "dcaeDeployParameters": { - "location_id": "", - "service_id": "", - "policy_id": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca" - } - }; - expect(loopCache.getGlobalProperties()).toStrictEqual(globelProp); - }); - - it('getDcaeDeploymentProperties', () => { - const deploymentProp = { - "location_id": "", - "service_id": "", - "policy_id": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca" - }; - expect(loopCache.getDcaeDeploymentProperties()).toStrictEqual(deploymentProp); - }); - - it('getMicroServiceForName', () => { - const msJson = { - "name": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca", - "modelType": "onap.policies.monitoring.cdap.tca.hi.lo.app", - "properties": {"domain": "measurementsForVfScaling"}, - "shared": false, - "jsonRepresentation": {"schema": {}} - }; - expect(loopCache.getMicroServiceForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(msJson); - expect(loopCache.getMicroServiceForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca_2")).toBeNull(); - }); - - it('getMicroServicePropertiesForName', () => { - const msProp = {"domain": "measurementsForVfScaling"}; - expect(loopCache.getMicroServicePropertiesForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(msProp); - expect(loopCache.getMicroServicePropertiesForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca_2")).toBeNull(); - }); - - it('getMicroServiceJsonRepresentationForName', () => { - const msJsonRepresentation = {"schema": {}}; - expect(loopCache.getMicroServiceJsonRepresentationForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(msJsonRepresentation); - }); - - it('getResourceDetailsVfProperty', () => { - const resourceVF = { - "vLoadBalancerMS 0": { - "resourceVendor": "Test", - "resourceVendorModelNumber": "", - "name": "vLoadBalancerMS", - "description": "vLBMS", - "invariantUUID": "1a31b9f2-e50d-43b7-89b3-a040250cf506", - "subcategory": "Load Balancer", - "category": "Application L4+", - "type": "VF", - "UUID": "b4c4f3d7-929e-4b6d-a1cd-57e952ddc3e6", - "version": "1.0", - "resourceVendorRelease": "1.0", - "customizationUUID": "465246dc-7748-45f4-a013-308d92922552" - } - }; - expect(loopCache.getResourceDetailsVfProperty()).toStrictEqual(resourceVF); - }); - - it('getResourceDetailsVfModuleProperty', () => { - const vfModule = { - "Vloadbalancerms..vpkg..module-1": { - "vfModuleModelInvariantUUID": "ca052563-eb92-4b5b-ad41-9111768ce043", - "vfModuleModelVersion": "1", - "vfModuleModelName": "Vloadbalancerms..vpkg..module-1", - "vfModuleModelUUID": "1e725ccc-b823-4f67-82b9-4f4367070dbc", - "vfModuleModelCustomizationUUID": "1bffdc31-a37d-4dee-b65c-dde623a76e52", - "min_vf_module_instances": 0, - "vf_module_label": "vpkg", - "max_vf_module_instances": 1, - "vf_module_type": "Expansion", - "isBase": false, - "initial_count": 0, - "volume_group": false - } - }; - expect(loopCache.getResourceDetailsVfModuleProperty()).toStrictEqual(vfModule); - }); - - it('getLoopLogsArray', () => { - const logs = [ - { - "id": 1, - "logType": "INFO", - "logComponent": "CLAMP", - "message": "Operational and Guard policies UPDATED", - "logInstant": "2019-07-08T09:44:37Z" - } - ]; - expect(loopCache.getLoopLogsArray()).toStrictEqual(logs); - }); - - it('getComponentStates', () => { - const component = { - "POLICY": { - "componentState": { - "stateName": "NOT_SENT", - "description": "The policies defined have NOT yet been created on the policy engine" - } - }, - "DCAE": { - "componentState": { - "stateName": "BLUEPRINT_DEPLOYED", - "description": "The DCAE blueprint has been found in the DCAE inventory but not yet instancianted for this loop" - } - } - }; - expect(loopCache.getComponentStates()).toStrictEqual(component); - }); - - it('updateGlobalProperties', () => { - const newGlobalProps = { - "dcaeDeployParameters": { - "location_id": "newLocation", - "service_id": "newServiceId", - "policy_id": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca_2" - } - }; - loopCache.updateGlobalProperties(newGlobalProps); - expect(loopCache.getGlobalProperties()).toStrictEqual(newGlobalProps); - }); - - it('updateOperationalPolicyProperties', () => { - const newOpPolicy = [{ - "name": "OPERATIONAL_h2NMX_v1_0_ResourceInstanceName1_tca_new", - "configurationsJson": { - "guard_policies": {}, - "operational_policy": { - "controlLoop": {}, - "policies": [] - } - } - }]; - loopCache.updateOperationalPolicyProperties(newOpPolicy); - expect(loopCache.getOperationalPolicies()).toStrictEqual(newOpPolicy); - }); - - it('updateMicroServiceProperties', () => { - const newMsPolicyProperties = {"domain": "measurementsForVfScalingNew"}; - loopCache.updateMicroServiceProperties("TCA_h2NMX_v1_0_ResourceInstanceName1_tca", newMsPolicyProperties); - expect(loopCache.getMicroServicePropertiesForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(newMsPolicyProperties); - }); - }); diff --git a/ui-react/src/__test__/LoopCache_mokeLoopJsonCache.json b/ui-react/src/__test__/LoopCache_mokeLoopJsonCache.json deleted file mode 100644 index 184eaf7cd..000000000 --- a/ui-react/src/__test__/LoopCache_mokeLoopJsonCache.json +++ /dev/null @@ -1,117 +0,0 @@ -{ - "name": "LOOP_Jbv1z_v1_0_ResourceInstanceName1_tca", - "dcaeBlueprintId": "typeId-3a942643-a8f7-4e54-b2c1-eea8daba2b17", - "globalPropertiesJson": { - "dcaeDeployParameters": { - "location_id": "", - "service_id": "", - "policy_id": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca" - } - }, - "modelPropertiesJson": { - "serviceDetails": { - "serviceType": "", - "namingPolicy": "", - "environmentContext": "General_Revenue-Bearing", - "serviceEcompNaming": "true", - "serviceRole": "", - "name": "vLoadBalancerMS", - "description": "vLBMS", - "invariantUUID": "30ec5b59-4799-48d8-ac5f-1058a6b0e48f", - "ecompGeneratedNaming": "true", - "category": "Network L4+", - "type": "Service", - "UUID": "63cac700-ab9a-4115-a74f-7eac85e3fce0", - "instantiationType": "A-la-carte" - }, - "resourceDetails": { - "CP": {}, - "VL": {}, - "VF": { - "vLoadBalancerMS 0": { - "resourceVendor": "Test", - "resourceVendorModelNumber": "", - "name": "vLoadBalancerMS", - "description": "vLBMS", - "invariantUUID": "1a31b9f2-e50d-43b7-89b3-a040250cf506", - "subcategory": "Load Balancer", - "category": "Application L4+", - "type": "VF", - "UUID": "b4c4f3d7-929e-4b6d-a1cd-57e952ddc3e6", - "version": "1.0", - "resourceVendorRelease": "1.0", - "customizationUUID": "465246dc-7748-45f4-a013-308d92922552" - } - }, - "CR": {}, - "VFC": {}, - "PNF": {}, - "Service": {}, - "CVFC": {}, - "Service Proxy": {}, - "Configuration": {}, - "AllottedResource": {}, - "VFModule": { - "Vloadbalancerms..vpkg..module-1": { - "vfModuleModelInvariantUUID": "ca052563-eb92-4b5b-ad41-9111768ce043", - "vfModuleModelVersion": "1", - "vfModuleModelName": "Vloadbalancerms..vpkg..module-1", - "vfModuleModelUUID": "1e725ccc-b823-4f67-82b9-4f4367070dbc", - "vfModuleModelCustomizationUUID": "1bffdc31-a37d-4dee-b65c-dde623a76e52", - "min_vf_module_instances": 0, - "vf_module_label": "vpkg", - "max_vf_module_instances": 1, - "vf_module_type": "Expansion", - "isBase": false, - "initial_count": 0, - "volume_group": false - } - } - } - }, - "lastComputedState": "DESIGN", - "components": { - "POLICY": { - "componentState": { - "stateName": "NOT_SENT", - "description": "The policies defined have NOT yet been created on the policy engine" - } - }, - "DCAE": { - "componentState": { - "stateName": "BLUEPRINT_DEPLOYED", - "description": "The DCAE blueprint has been found in the DCAE inventory but not yet instancianted for this loop" - } - } - }, - "operationalPolicies": [ - { - "name": "OPERATIONAL_h2NMX_v1_0_ResourceInstanceName1_tca", - "configurationsJson": { - "guard_policies": {}, - "operational_policy": { - "controlLoop": {}, - "policies": [] - } - } - } - ], - "microServicePolicies": [ - { - "name": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca", - "modelType": "onap.policies.monitoring.cdap.tca.hi.lo.app", - "properties": {"domain": "measurementsForVfScaling"}, - "shared": false, - "jsonRepresentation": {"schema": {}} - } - ], - "loopLogs": [ - { - "id": 1, - "logType": "INFO", - "logComponent": "CLAMP", - "message": "Operational and Guard policies UPDATED", - "logInstant": "2019-07-08T09:44:37Z" - } - ] -} diff --git a/ui-react/src/__test__/OpenLoopModal.test.js b/ui-react/src/__test__/OpenLoopModal.test.js deleted file mode 100644 index 044eeda89..000000000 --- a/ui-react/src/__test__/OpenLoopModal.test.js +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * 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. - * ============LICENSE_END============================================ - * =================================================================== - * - */ -import React from 'react'; -import { shallow } from 'enzyme'; -import OpenLoopModal from '../components/dialogs/OpenLoop/OpenLoopModal'; - -describe('Verify OpenLoopModal', () => { - - it('Test the render method', () => { - const component = shallow(); - expect(component).toMatchSnapshot(); - }); - - -}); diff --git a/ui-react/src/__test__/__snapshots__/OpenLoopModal.test.js.snap b/ui-react/src/__test__/__snapshots__/OpenLoopModal.test.js.snap deleted file mode 100644 index cb8b8fd30..000000000 --- a/ui-react/src/__test__/__snapshots__/OpenLoopModal.test.js.snap +++ /dev/null @@ -1,3 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Verify OpenLoopModal Test the render method 1`] = `ShallowWrapper {}`; diff --git a/ui-react/src/api/LoopCache.test.js b/ui-react/src/api/LoopCache.test.js new file mode 100644 index 000000000..f67bc0aa0 --- /dev/null +++ b/ui-react/src/api/LoopCache.test.js @@ -0,0 +1,205 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * 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. + * ============LICENSE_END============================================ + * =================================================================== + * + */ +import LoopCache from '../api/LoopCache'; + +const json = require('./LoopCache_mokeLoopJsonCache.json'); + +describe('Verify LoopCache functions', () => { + const loopCache = new LoopCache(json); + it('getLoopName', () => { + expect(loopCache.getLoopName()).toBe("LOOP_Jbv1z_v1_0_ResourceInstanceName1_tca"); + }); + + it('getOperationalPolicyConfigurationJson', () => { + const opPolicyConfig = { + "guard_policies": {}, + "operational_policy": { + "controlLoop": {}, + "policies": [] + } + }; + expect(loopCache.getOperationalPolicyConfigurationJson()).toStrictEqual(opPolicyConfig); + }); + + it('getOperationalPolicies', () => { + const opPolicy = [{ + "name": "OPERATIONAL_h2NMX_v1_0_ResourceInstanceName1_tca", + "configurationsJson": { + "guard_policies": {}, + "operational_policy": { + "controlLoop": {}, + "policies": [] + + } + } + }]; + expect(loopCache.getOperationalPolicies()).toStrictEqual(opPolicy); + }); + + it('getGlobalProperties', () => { + const globelProp = { + "dcaeDeployParameters": { + "location_id": "", + "service_id": "", + "policy_id": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca" + } + }; + expect(loopCache.getGlobalProperties()).toStrictEqual(globelProp); + }); + + it('getDcaeDeploymentProperties', () => { + const deploymentProp = { + "location_id": "", + "service_id": "", + "policy_id": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca" + }; + expect(loopCache.getDcaeDeploymentProperties()).toStrictEqual(deploymentProp); + }); + + it('getMicroServiceForName', () => { + const msJson = { + "name": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca", + "modelType": "onap.policies.monitoring.cdap.tca.hi.lo.app", + "properties": {"domain": "measurementsForVfScaling"}, + "shared": false, + "jsonRepresentation": {"schema": {}} + }; + expect(loopCache.getMicroServiceForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(msJson); + expect(loopCache.getMicroServiceForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca_2")).toBeNull(); + }); + + it('getMicroServicePropertiesForName', () => { + const msProp = {"domain": "measurementsForVfScaling"}; + expect(loopCache.getMicroServicePropertiesForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(msProp); + expect(loopCache.getMicroServicePropertiesForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca_2")).toBeNull(); + }); + + it('getMicroServiceJsonRepresentationForName', () => { + const msJsonRepresentation = {"schema": {}}; + expect(loopCache.getMicroServiceJsonRepresentationForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(msJsonRepresentation); + }); + + it('getResourceDetailsVfProperty', () => { + const resourceVF = { + "vLoadBalancerMS 0": { + "resourceVendor": "Test", + "resourceVendorModelNumber": "", + "name": "vLoadBalancerMS", + "description": "vLBMS", + "invariantUUID": "1a31b9f2-e50d-43b7-89b3-a040250cf506", + "subcategory": "Load Balancer", + "category": "Application L4+", + "type": "VF", + "UUID": "b4c4f3d7-929e-4b6d-a1cd-57e952ddc3e6", + "version": "1.0", + "resourceVendorRelease": "1.0", + "customizationUUID": "465246dc-7748-45f4-a013-308d92922552" + } + }; + expect(loopCache.getResourceDetailsVfProperty()).toStrictEqual(resourceVF); + }); + + it('getResourceDetailsVfModuleProperty', () => { + const vfModule = { + "Vloadbalancerms..vpkg..module-1": { + "vfModuleModelInvariantUUID": "ca052563-eb92-4b5b-ad41-9111768ce043", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..vpkg..module-1", + "vfModuleModelUUID": "1e725ccc-b823-4f67-82b9-4f4367070dbc", + "vfModuleModelCustomizationUUID": "1bffdc31-a37d-4dee-b65c-dde623a76e52", + "min_vf_module_instances": 0, + "vf_module_label": "vpkg", + "max_vf_module_instances": 1, + "vf_module_type": "Expansion", + "isBase": false, + "initial_count": 0, + "volume_group": false + } + }; + expect(loopCache.getResourceDetailsVfModuleProperty()).toStrictEqual(vfModule); + }); + + it('getLoopLogsArray', () => { + const logs = [ + { + "id": 1, + "logType": "INFO", + "logComponent": "CLAMP", + "message": "Operational and Guard policies UPDATED", + "logInstant": "2019-07-08T09:44:37Z" + } + ]; + expect(loopCache.getLoopLogsArray()).toStrictEqual(logs); + }); + + it('getComponentStates', () => { + const component = { + "POLICY": { + "componentState": { + "stateName": "NOT_SENT", + "description": "The policies defined have NOT yet been created on the policy engine" + } + }, + "DCAE": { + "componentState": { + "stateName": "BLUEPRINT_DEPLOYED", + "description": "The DCAE blueprint has been found in the DCAE inventory but not yet instancianted for this loop" + } + } + }; + expect(loopCache.getComponentStates()).toStrictEqual(component); + }); + + it('updateGlobalProperties', () => { + const newGlobalProps = { + "dcaeDeployParameters": { + "location_id": "newLocation", + "service_id": "newServiceId", + "policy_id": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca_2" + } + }; + loopCache.updateGlobalProperties(newGlobalProps); + expect(loopCache.getGlobalProperties()).toStrictEqual(newGlobalProps); + }); + + it('updateOperationalPolicyProperties', () => { + const newOpPolicy = [{ + "name": "OPERATIONAL_h2NMX_v1_0_ResourceInstanceName1_tca_new", + "configurationsJson": { + "guard_policies": {}, + "operational_policy": { + "controlLoop": {}, + "policies": [] + } + } + }]; + loopCache.updateOperationalPolicyProperties(newOpPolicy); + expect(loopCache.getOperationalPolicies()).toStrictEqual(newOpPolicy); + }); + + it('updateMicroServiceProperties', () => { + const newMsPolicyProperties = {"domain": "measurementsForVfScalingNew"}; + loopCache.updateMicroServiceProperties("TCA_h2NMX_v1_0_ResourceInstanceName1_tca", newMsPolicyProperties); + expect(loopCache.getMicroServicePropertiesForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(newMsPolicyProperties); + }); + }); diff --git a/ui-react/src/api/LoopCache_mokeLoopJsonCache.json b/ui-react/src/api/LoopCache_mokeLoopJsonCache.json new file mode 100644 index 000000000..184eaf7cd --- /dev/null +++ b/ui-react/src/api/LoopCache_mokeLoopJsonCache.json @@ -0,0 +1,117 @@ +{ + "name": "LOOP_Jbv1z_v1_0_ResourceInstanceName1_tca", + "dcaeBlueprintId": "typeId-3a942643-a8f7-4e54-b2c1-eea8daba2b17", + "globalPropertiesJson": { + "dcaeDeployParameters": { + "location_id": "", + "service_id": "", + "policy_id": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca" + } + }, + "modelPropertiesJson": { + "serviceDetails": { + "serviceType": "", + "namingPolicy": "", + "environmentContext": "General_Revenue-Bearing", + "serviceEcompNaming": "true", + "serviceRole": "", + "name": "vLoadBalancerMS", + "description": "vLBMS", + "invariantUUID": "30ec5b59-4799-48d8-ac5f-1058a6b0e48f", + "ecompGeneratedNaming": "true", + "category": "Network L4+", + "type": "Service", + "UUID": "63cac700-ab9a-4115-a74f-7eac85e3fce0", + "instantiationType": "A-la-carte" + }, + "resourceDetails": { + "CP": {}, + "VL": {}, + "VF": { + "vLoadBalancerMS 0": { + "resourceVendor": "Test", + "resourceVendorModelNumber": "", + "name": "vLoadBalancerMS", + "description": "vLBMS", + "invariantUUID": "1a31b9f2-e50d-43b7-89b3-a040250cf506", + "subcategory": "Load Balancer", + "category": "Application L4+", + "type": "VF", + "UUID": "b4c4f3d7-929e-4b6d-a1cd-57e952ddc3e6", + "version": "1.0", + "resourceVendorRelease": "1.0", + "customizationUUID": "465246dc-7748-45f4-a013-308d92922552" + } + }, + "CR": {}, + "VFC": {}, + "PNF": {}, + "Service": {}, + "CVFC": {}, + "Service Proxy": {}, + "Configuration": {}, + "AllottedResource": {}, + "VFModule": { + "Vloadbalancerms..vpkg..module-1": { + "vfModuleModelInvariantUUID": "ca052563-eb92-4b5b-ad41-9111768ce043", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..vpkg..module-1", + "vfModuleModelUUID": "1e725ccc-b823-4f67-82b9-4f4367070dbc", + "vfModuleModelCustomizationUUID": "1bffdc31-a37d-4dee-b65c-dde623a76e52", + "min_vf_module_instances": 0, + "vf_module_label": "vpkg", + "max_vf_module_instances": 1, + "vf_module_type": "Expansion", + "isBase": false, + "initial_count": 0, + "volume_group": false + } + } + } + }, + "lastComputedState": "DESIGN", + "components": { + "POLICY": { + "componentState": { + "stateName": "NOT_SENT", + "description": "The policies defined have NOT yet been created on the policy engine" + } + }, + "DCAE": { + "componentState": { + "stateName": "BLUEPRINT_DEPLOYED", + "description": "The DCAE blueprint has been found in the DCAE inventory but not yet instancianted for this loop" + } + } + }, + "operationalPolicies": [ + { + "name": "OPERATIONAL_h2NMX_v1_0_ResourceInstanceName1_tca", + "configurationsJson": { + "guard_policies": {}, + "operational_policy": { + "controlLoop": {}, + "policies": [] + } + } + } + ], + "microServicePolicies": [ + { + "name": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca", + "modelType": "onap.policies.monitoring.cdap.tca.hi.lo.app", + "properties": {"domain": "measurementsForVfScaling"}, + "shared": false, + "jsonRepresentation": {"schema": {}} + } + ], + "loopLogs": [ + { + "id": 1, + "logType": "INFO", + "logComponent": "CLAMP", + "message": "Operational and Guard policies UPDATED", + "logInstant": "2019-07-08T09:44:37Z" + } + ] +} diff --git a/ui-react/src/components/dialogs/OpenLoop/OpenLoopModal.test.js b/ui-react/src/components/dialogs/OpenLoop/OpenLoopModal.test.js new file mode 100644 index 000000000..6ba8f40a5 --- /dev/null +++ b/ui-react/src/components/dialogs/OpenLoop/OpenLoopModal.test.js @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * 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. + * ============LICENSE_END============================================ + * =================================================================== + * + */ +import React from 'react'; +import { shallow } from 'enzyme'; +import OpenLoopModal from './OpenLoopModal'; + +describe('Verify OpenLoopModal', () => { + + beforeEach(() => { + fetch.resetMocks() + }) + + it('Test the render method', () => { + fetch.mockResponseOnce(JSON.stringify([ + "LOOP_gmtAS_v1_0_ResourceInstanceName1_tca", + "LOOP_gmtAS_v1_0_ResourceInstanceName1_tca_3", + "LOOP_gmtAS_v1_0_ResourceInstanceName2_tca_2" + ])) + + const component = shallow(); + expect(component).toMatchSnapshot(); + }); + + +}); diff --git a/ui-react/src/components/dialogs/OpenLoop/__snapshots__/OpenLoopModal.test.js.snap b/ui-react/src/components/dialogs/OpenLoop/__snapshots__/OpenLoopModal.test.js.snap new file mode 100644 index 000000000..5fd9e8aa5 --- /dev/null +++ b/ui-react/src/components/dialogs/OpenLoop/__snapshots__/OpenLoopModal.test.js.snap @@ -0,0 +1,92 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Verify OpenLoopModal Test the render method 1`] = ` + + + + Open Model + + + + + + Model Name + + + + + + + + + Read Only + + + + + + + + + + +`; diff --git a/ui-react/src/setupTests.js b/ui-react/src/setupTests.js index fc7b0dce1..55d746052 100644 --- a/ui-react/src/setupTests.js +++ b/ui-react/src/setupTests.js @@ -1,4 +1,28 @@ -import Enzyme from 'enzyme'; +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * 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. + * ============LICENSE_END============================================ + * =================================================================== + * + */ + +import { configure } from 'enzyme'; import Adapter from 'enzyme-adapter-react-16'; -Enzyme.configure({ adapter: new Adapter() }); +configure({ adapter: new Adapter() }); +global.fetch = require('jest-fetch-mock'); \ No newline at end of file -- cgit 1.2.3-korg