aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-ui/test/softwareProduct/attachments
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-ui/test/softwareProduct/attachments')
-rw-r--r--openecomp-ui/test/softwareProduct/attachments/SoftwareProductAttachmentsView.test.js214
-rw-r--r--openecomp-ui/test/softwareProduct/attachments/setup/heatSetup.test.js49
-rw-r--r--openecomp-ui/test/softwareProduct/attachments/setup/heatSetupActionHelper.test.js142
-rw-r--r--openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationActionHelper.test.js (renamed from openecomp-ui/test/softwareProduct/attachments/SoftwareproductAttachmentsHelper.test.js)53
-rw-r--r--openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationView.test.js184
5 files changed, 443 insertions, 199 deletions
diff --git a/openecomp-ui/test/softwareProduct/attachments/SoftwareProductAttachmentsView.test.js b/openecomp-ui/test/softwareProduct/attachments/SoftwareProductAttachmentsView.test.js
index 839176c970..5dfe98f273 100644
--- a/openecomp-ui/test/softwareProduct/attachments/SoftwareProductAttachmentsView.test.js
+++ b/openecomp-ui/test/softwareProduct/attachments/SoftwareProductAttachmentsView.test.js
@@ -1,198 +1,76 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 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
- *
+ *
+ * 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=========================================================
+ * 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.
*/
-import expect from 'expect';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
-import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js';
+import {VSPAttachmentTreeNodeWithChildrenFactory, VSPAttachmentDetailedError} from 'test-utils/factories/softwareProduct/SoftwareProductAttachmentsFactories.js';
+import {defaultStoreFactory} from 'test-utils/factories/onboard/OnboardingCatalogFactories.js';
+import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js';
import SoftwareProductAttachmentsView from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx';
-import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
+import {tabsMapping} from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsConstants.js';
+import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
-
-describe('SoftwareProductAttachments Modal Mapper and View Classes', () => {
-
- it ('mapStateToProps mapper exists', () => {
- expect(mapStateToProps).toExist();
+describe('SoftwareProduct Attachments - View: ', function () {
+ it('should mapper exist', () => {
+ expect(mapStateToProps).toBeTruthy();
});
+ it('should mapper return default data', () => {
- it ('mapStateToProps check data', () => {
+ let attachmentsTree = VSPAttachmentTreeNodeWithChildrenFactory.build();
+ let errorList = VSPAttachmentDetailedError.buildList(3);
+ let versionControllerData = VersionControllerUtilsFactory.build();
- const currentSoftwareProduct = {
- name: 'VSp',
- description: 'dfdf',
- vendorName: 'V1',
- vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
- category: 'resourceNewCategory.application l4+',
- subCategory: 'resourceNewCategory.application l4+.database',
- id: 'D4774719D085414E9D5642D1ACD59D20',
- version: '0.10',
- viewableVersions: ['0.1', '0.2'],
- status: versionStatusEnum.CHECK_OUT_STATUS,
- lockingUser: 'cs0008'
- };
- const atTree = {
- 'children': [
- {
- 'name': 'HEAT',
- 'expanded': true,
- 'type': 'heat',
- 'children': [
- {
- 'name': 'heat_zxeyCtMHhf2.yaml',
- 'expanded': true,
- 'type': 'heat',
- 'errors': [
- {
- 'level': 'WARNING',
- 'message': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4'
- }
- ],
- 'children': [
- {
- 'name': 'heat_env_zxeyCtMHhf2.env',
- 'type': 'env'
- }
- ]
- }
- ]
- }
- ]
- };
- const errorList = [
- {
- 'errorLevel': 'WARNING',
- 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4',
- 'name': 'heat_zxeyCtMHhf2.yaml',
- 'hasParent': false,
- 'parentName': 'HEAT',
- 'type': 'heat'
+ let softwareProductAttachments = {
+ heatSetup: {},
+ heatValidation: {
+ attachmentsTree,
+ errorList
},
- {
- 'errorLevel': 'WARNING',
- 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_3',
- 'name': 'heat_zxeyCtMHhf2.yaml',
- 'hasParent': false,
- 'parentName': 'HEAT',
- 'type': 'heat'
- }
- ];
-
- var obj = {
- softwareProduct: {
- softwareProductEditor: {
- data:currentSoftwareProduct
- }, softwareProductAttachments:
- {
- attachmentsTree: atTree,
- errorList: errorList
- }
- }
+ heatSetupCache: {},
+ activeTab: tabsMapping.SETUP
};
-
- var results = mapStateToProps(obj);
- expect(results.attachmentsTree).toExist();
- expect(results.errorList).toExist();
- expect(results.hoveredNode).toBe(undefined);
- expect(results.selectedNode).toBe(undefined);
+ let data = defaultStoreFactory.build({softwareProduct: {softwareProductAttachments, softwareProductEditor: {data: {...versionControllerData}}}});
+ var result = mapStateToProps(data);
+ expect(result).toBeTruthy();
+ expect(result.isValidationAvailable).toBe(false);
});
+ it('view test', () => {
- it('function does exist', () => {
+ let attachmentsTree = VSPAttachmentTreeNodeWithChildrenFactory.build();
+ let errorList = VSPAttachmentDetailedError.buildList(3);
+ let versionControllerData = VersionControllerUtilsFactory.build();
- const currentSoftwareProduct = {
- name: 'VSp',
- description: 'dfdf',
- vendorName: 'V1',
- vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
- category: 'resourceNewCategory.application l4+',
- subCategory: 'resourceNewCategory.application l4+.database',
- id: 'D4774719D085414E9D5642D1ACD59D20',
- version: '0.10',
- viewableVersions: ['0.1', '0.2'],
- status: versionStatusEnum.CHECK_OUT_STATUS,
- lockingUser: 'cs0008'
- };
- const versionControllerData = {
- version: currentSoftwareProduct.version,
- viewableVersions:currentSoftwareProduct.viewableVersions,
- status: currentSoftwareProduct.status,
- isCheckedOut: true
- };
- const atTree = {
- 'children': [
- {
- 'name': 'HEAT',
- 'expanded': true,
- 'type': 'heat',
- 'children': [
- {
- 'name': 'heat_zxeyCtMHhf2.yaml',
- 'expanded': true,
- 'type': 'heat',
- 'errors': [
- {
- 'level': 'WARNING',
- 'message': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4'
- }
- ],
- 'children': [
- {
- 'name': 'heat_env_zxeyCtMHhf2.env',
- 'type': 'env'
- }
- ]
- }
- ]
- }
- ]
- };
- const errorList = [
- {
- 'errorLevel': 'WARNING',
- 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4',
- 'name': 'heat_zxeyCtMHhf2.yaml',
- 'hasParent': false,
- 'parentName': 'HEAT',
- 'type': 'heat'
+ let softwareProductAttachments = {
+ heatSetup: {},
+ heatValidation: {
+ attachmentsTree,
+ errorList
},
- {
- 'errorLevel': 'WARNING',
- 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_3',
- 'name': 'heat_zxeyCtMHhf2.yaml',
- 'hasParent': false,
- 'parentName': 'HEAT',
- 'type': 'heat'
- }
- ];
-
+ shouldOpenValidationTab: false
+ };
+ let data = defaultStoreFactory.build({softwareProduct: {softwareProductAttachments, softwareProductEditor: {data: {...versionControllerData}}}});
+ var params = mapStateToProps(data);
var renderer = TestUtils.createRenderer();
- renderer.render(<SoftwareProductAttachmentsView
- versionControllerData={versionControllerData}
- currentSoftwareProduct={currentSoftwareProduct}
- attachmentsTree={atTree}
- errorList={errorList}/>);
+ renderer.render(<SoftwareProductAttachmentsView {...params}/>);
var renderedOutput = renderer.getRenderOutput();
- expect(renderedOutput).toExist();
+ expect(renderedOutput).toBeTruthy();
});
});
diff --git a/openecomp-ui/test/softwareProduct/attachments/setup/heatSetup.test.js b/openecomp-ui/test/softwareProduct/attachments/setup/heatSetup.test.js
new file mode 100644
index 0000000000..80e9401f1a
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/attachments/setup/heatSetup.test.js
@@ -0,0 +1,49 @@
+/*!
+ * Copyright (C) 2017 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.
+ */
+import React from 'react';
+
+import TestUtils from 'react-addons-test-utils';
+import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetup.js';
+import HeatSetupView from 'sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupView.jsx';
+import {storeCreator} from 'sdc-app/AppStore.js';
+
+describe('Heat Setup View test: ', function () {
+ it('should mapper exist', () => {
+ expect(mapStateToProps).toBeTruthy();
+ });
+
+ it('should mapper return basic data', () => {
+
+ const store = storeCreator();
+
+ var result = mapStateToProps(store.getState());
+ expect(result).toBeTruthy();
+ expect(result.modules.length).toEqual(0);
+ expect(result.unassigned.length).toEqual(0);
+ expect(result.artifacts.length).toEqual(0);
+ expect(result.nested.length).toEqual(0);
+ });
+
+ it('view test', () => {
+
+ const store = storeCreator();
+
+ var params = mapStateToProps(store.getState());
+
+ let heatSetupView = TestUtils.renderIntoDocument(<HeatSetupView {...params}/>);
+ expect(heatSetupView).toBeTruthy();
+ });
+});
diff --git a/openecomp-ui/test/softwareProduct/attachments/setup/heatSetupActionHelper.test.js b/openecomp-ui/test/softwareProduct/attachments/setup/heatSetupActionHelper.test.js
new file mode 100644
index 0000000000..99bbfeac11
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/attachments/setup/heatSetupActionHelper.test.js
@@ -0,0 +1,142 @@
+/*!
+ * Copyright (C) 2017 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.
+ */
+
+import HeatSetupActionHelper from 'sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupActionHelper.js';
+import {storeCreator} from 'sdc-app/AppStore.js';
+import deepFreeze from 'deep-freeze';
+import {heatSetupManifest} from 'test-utils/factories/softwareProduct/SoftwareProductAttachmentsFactories.js';
+import {actionTypes as HeatSetupActions, fileTypes as HeatSetupFileTypes} from 'sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupConstants.js';
+
+describe('Heat Setup Action Helper test', () => {
+
+ it('function does exist', () => {
+ expect(HeatSetupActionHelper).toBeTruthy();
+ });
+
+ it('manifest load test', () => {
+
+ const store = storeCreator();
+
+ const manifest = heatSetupManifest.build();
+ store.dispatch({
+ type: HeatSetupActions.MANIFEST_LOADED,
+ response: manifest
+ });
+
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.modules.length).toBe(manifest.modules.length);
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.nested.length).toBe(manifest.nested.length);
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.unassigned.length).toBe(manifest.unassigned.length);
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.artifacts.length).toBe(manifest.artifacts.length);
+
+ });
+
+ it('add module action test', () => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const manifest = heatSetupManifest.build();
+ store.dispatch({
+ type: HeatSetupActions.MANIFEST_LOADED,
+ response: manifest
+ });
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.modules.length).toBe(manifest.modules.length);
+ HeatSetupActionHelper.addModule(store.dispatch);
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.modules.length).toBe(manifest.modules.length + 1);
+
+ });
+
+ it('delete module action test', () => {
+
+ const store = storeCreator();
+
+ const manifest = heatSetupManifest.build();
+ store.dispatch({
+ type: HeatSetupActions.MANIFEST_LOADED,
+ response: manifest
+ });
+ HeatSetupActionHelper.deleteModule(store.dispatch, manifest.modules[0].name);
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.modules.length).toBe(manifest.modules.length - 1);
+
+ });
+
+ it('rename module action test', () => {
+
+ const store = storeCreator();
+
+ const manifest = heatSetupManifest.build();
+ store.dispatch({
+ type: HeatSetupActions.MANIFEST_LOADED,
+ response: manifest
+ });
+ const newName = 'newName';
+ HeatSetupActionHelper.renameModule(store.dispatch, {oldName: manifest.modules[0].name, newName});
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.modules[0].name).toBe(newName);
+
+ });
+
+ it('change module type action test', () => {
+
+ const store = storeCreator();
+
+ const manifest = heatSetupManifest.build();
+ store.dispatch({
+ type: HeatSetupActions.MANIFEST_LOADED,
+ response: manifest
+ });
+ const newValue = 'newvalue.env';
+ HeatSetupActionHelper.changeModuleFileType(store.dispatch,
+ {
+ module: manifest.modules[0],
+ value: {value: newValue},
+ type: HeatSetupFileTypes.ENV.label
+ });
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.modules[0].env).toBe(newValue);
+ });
+
+ it('change artifacts list action test', () => {
+
+ const store = storeCreator();
+
+ const manifest = heatSetupManifest.build();
+ store.dispatch({
+ type: HeatSetupActions.MANIFEST_LOADED,
+ response: manifest
+ });
+ const artifacts = store.getState().softwareProduct.softwareProductAttachments.heatSetup.artifacts;
+ const newArtifacts = [...artifacts, manifest.unassigned[0]].map(str => (typeof str === 'string' ? {value: str, label: str} : str));;
+ HeatSetupActionHelper.changeArtifactList(store.dispatch, newArtifacts);
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.artifacts[1]).toBe(manifest.unassigned[0]);
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.unassigned.length).toBe(manifest.unassigned.length - 1);
+ });
+
+ it('add All Unassigned Files To Artifacts action test', () => {
+
+ const store = storeCreator();
+
+ const manifest = heatSetupManifest.build();
+ store.dispatch({
+ type: HeatSetupActions.MANIFEST_LOADED,
+ response: manifest
+ });
+ const artifacts = store.getState().softwareProduct.softwareProductAttachments.heatSetup.artifacts;
+ const unassigned = store.getState().softwareProduct.softwareProductAttachments.heatSetup.unassigned;
+ const newArtifacts = [...artifacts, ...unassigned];
+ HeatSetupActionHelper.addAllUnassignedFilesToArtifacts(store.dispatch, true);
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.artifacts).toEqual(newArtifacts);
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.unassigned).toEqual([]);
+ });
+
+});
diff --git a/openecomp-ui/test/softwareProduct/attachments/SoftwareproductAttachmentsHelper.test.js b/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationActionHelper.test.js
index 851560caa8..d8a5d1fad6 100644
--- a/openecomp-ui/test/softwareProduct/attachments/SoftwareproductAttachmentsHelper.test.js
+++ b/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationActionHelper.test.js
@@ -1,38 +1,29 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 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
- *
+ *
+ * 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=========================================================
+ * 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.
*/
-import expect from 'expect';
-import SoftwareProductAttachmentsActionHelper from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsActionHelper.js';
+import HeatValidationActionHelper from 'sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationActionHelper.js';
import {storeCreator} from 'sdc-app/AppStore.js';
import deepFreeze from 'deep-freeze';
import {actionTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js';
+import {nodeFilters} from 'sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationConstants.js';
-
-
-
-
-
-describe('SoftwareProductAttachments ActionHelper', () => {
+describe('HeatValidationActionHelper ActionHelper', () => {
it('function does exist', () => {
- expect(SoftwareProductAttachmentsActionHelper).toExist();
+ expect(HeatValidationActionHelper).toBeTruthy();
});
it('toggleExpanded function check', () => {
@@ -86,9 +77,9 @@ describe('SoftwareProductAttachments ActionHelper', () => {
response: currentSoftwareProduct
});
- expect(store.getState().softwareProduct.softwareProductAttachments.attachmentsTree.children[0].expanded).toBe(true);
- SoftwareProductAttachmentsActionHelper.toggleExpanded(store.dispatch, {path:[0]});
- expect(store.getState().softwareProduct.softwareProductAttachments.attachmentsTree.children[0].expanded).toBe(false);
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatValidation.attachmentsTree.children[0].expanded).toBe(true);
+ HeatValidationActionHelper.toggleExpanded(store.dispatch, {path:[0]});
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatValidation.attachmentsTree.children[0].expanded).toBe(false);
});
it('onSelectNode & onUnselectNode function check', () => {
@@ -96,7 +87,7 @@ describe('SoftwareProductAttachments ActionHelper', () => {
const validationData = {
importStructure: {
- HEAT: [
+ heat: [
{
fileName: 'hot-mog-0108-bs1271.yml',
env: {
@@ -133,7 +124,7 @@ describe('SoftwareProductAttachments ActionHelper', () => {
};
deepFreeze(currentSoftwareProduct);
-
+
const store = storeCreator();
deepFreeze(store.getState());
@@ -142,11 +133,11 @@ describe('SoftwareProductAttachments ActionHelper', () => {
response: currentSoftwareProduct
});
let expectedNodeName = 'name';
- expect(store.getState().softwareProduct.softwareProductAttachments.selectedNode).toBe(undefined);
- SoftwareProductAttachmentsActionHelper.onSelectNode(store.dispatch, {nodeName:expectedNodeName});
- expect(store.getState().softwareProduct.softwareProductAttachments.selectedNode).toBe(expectedNodeName);
- SoftwareProductAttachmentsActionHelper.onUnselectNode(store.dispatch);
- expect(store.getState().softwareProduct.softwareProductAttachments.selectedNode).toBe(undefined);
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatValidation.selectedNode).toBe(nodeFilters.ALL);
+ HeatValidationActionHelper.onSelectNode(store.dispatch, {nodeName:expectedNodeName});
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatValidation.selectedNode).toBe(expectedNodeName);
+ HeatValidationActionHelper.onDeselectNode(store.dispatch);
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatValidation.selectedNode).toBe(nodeFilters.ALL);
});
diff --git a/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationView.test.js b/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationView.test.js
new file mode 100644
index 0000000000..a5ba297d2b
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationView.test.js
@@ -0,0 +1,184 @@
+/*!
+ * Copyright (C) 2017 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.
+ */
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidation.js';
+
+import HeatValidationView from 'sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationView.jsx';
+import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
+
+
+describe('SoftwareProductAttachments Modal Mapper and View Classes', () => {
+
+ it ('mapStateToProps mapper exists', () => {
+ expect(mapStateToProps).toBeTruthy();
+ });
+
+
+ it ('mapStateToProps check data', () => {
+
+ const currentSoftwareProduct = {
+ name: 'VSp',
+ description: 'dfdf',
+ vendorName: 'V1',
+ vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
+ category: 'resourceNewCategory.application l4+',
+ subCategory: 'resourceNewCategory.application l4+.database',
+ id: 'D4774719D085414E9D5642D1ACD59D20',
+ version: '0.10',
+ viewableVersions: ['0.1', '0.2'],
+ status: versionStatusEnum.CHECK_OUT_STATUS,
+ lockingUser: 'cs0008'
+ };
+ const atTree = {
+ 'children': [
+ {
+ 'name': 'HEAT',
+ 'expanded': true,
+ 'type': 'heat',
+ 'children': [
+ {
+ 'name': 'heat_zxeyCtMHhf2.yaml',
+ 'expanded': true,
+ 'type': 'heat',
+ 'errors': [
+ {
+ 'level': 'WARNING',
+ 'message': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4'
+ }
+ ],
+ 'children': [
+ {
+ 'name': 'heat_env_zxeyCtMHhf2.env',
+ 'type': 'env'
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ };
+ const errorList = [
+ {
+ 'errorLevel': 'WARNING',
+ 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4',
+ 'name': 'heat_zxeyCtMHhf2.yaml',
+ 'hasParent': false,
+ 'parentName': 'HEAT',
+ 'type': 'heat'
+ },
+ {
+ 'errorLevel': 'WARNING',
+ 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_3',
+ 'name': 'heat_zxeyCtMHhf2.yaml',
+ 'hasParent': false,
+ 'parentName': 'HEAT',
+ 'type': 'heat'
+ }
+ ];
+
+ var obj = {
+ softwareProduct: {
+ softwareProductEditor: {
+ data:currentSoftwareProduct
+ }, softwareProductAttachments:
+ {
+ heatValidation: {
+ attachmentsTree: atTree,
+ errorList: errorList
+ }
+ }
+ }
+ };
+
+ var results = mapStateToProps(obj);
+ expect(results.attachmentsTree).toBeTruthy();
+ expect(results.errorList).toBeTruthy();
+ expect(results.currentErrors).toBeTruthy();
+ expect(results.currentWarnings).toBeTruthy();
+ expect(results.selectedNode).toBe(undefined);
+ });
+
+
+ it('function does exist', () => {
+
+ const atTree = {
+ 'children': [
+ {
+ 'name': 'HEAT',
+ 'expanded': true,
+ 'type': 'heat',
+ 'children': [
+ {
+ 'name': 'heat_zxeyCtMHhf2.yaml',
+ 'expanded': true,
+ 'type': 'heat',
+ 'errors': [
+ {
+ 'level': 'WARNING',
+ 'message': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4'
+ }
+ ],
+ 'children': [
+ {
+ 'name': 'heat_env_zxeyCtMHhf2.env',
+ 'type': 'env'
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ };
+ const errorList = [
+ {
+ 'errorLevel': 'WARNING',
+ 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4',
+ 'name': 'heat_zxeyCtMHhf2.yaml',
+ 'hasParent': false,
+ 'parentName': 'HEAT',
+ 'type': 'heat'
+ },
+ {
+ 'errorLevel': 'WARNING',
+ 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_3',
+ 'name': 'heat_zxeyCtMHhf2.yaml',
+ 'hasParent': false,
+ 'parentName': 'HEAT',
+ 'type': 'heat'
+ }
+ ];
+ var currentErrors = [];
+ var currentWarnings = [];
+ var onSelect = () => { return null; } ;
+ var onDeSelect = () => { return null; } ;
+ var onToggle = () => { return null; } ;
+
+ var renderer = TestUtils.createRenderer();
+ renderer.render(<HeatValidationView
+ attachmentsTree={atTree}
+ errorList={errorList}
+ currentWarnings={currentWarnings}
+ currentErrors={currentErrors}
+ onSelectNode={onSelect}
+ onDeselectNode={onDeSelect}
+ toggleExpanded = {onToggle} />);
+ var renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toBeTruthy();
+ });
+
+});