Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 1 | /*- |
| 2 | * ============LICENSE_START======================================================= |
| 3 | * SDC |
| 4 | * ================================================================================ |
| 5 | * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. |
| 6 | * ================================================================================ |
| 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
| 10 | * |
| 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | * |
| 13 | * Unless required by applicable law or agreed to in writing, software |
| 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | * See the License for the specific language governing permissions and |
| 17 | * limitations under the License. |
| 18 | * ============LICENSE_END========================================================= |
| 19 | */ |
| 20 | |
| 21 | import expect from 'expect'; |
| 22 | import React from 'react'; |
| 23 | import TestUtils from 'react-addons-test-utils'; |
| 24 | import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js'; |
| 25 | |
| 26 | import SoftwareProductAttachmentsView from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx'; |
| 27 | import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; |
| 28 | |
| 29 | |
| 30 | describe('SoftwareProductAttachments Modal Mapper and View Classes', () => { |
| 31 | |
| 32 | it ('mapStateToProps mapper exists', () => { |
| 33 | expect(mapStateToProps).toExist(); |
| 34 | }); |
| 35 | |
| 36 | |
| 37 | it ('mapStateToProps check data', () => { |
| 38 | |
| 39 | const currentSoftwareProduct = { |
| 40 | name: 'VSp', |
| 41 | description: 'dfdf', |
| 42 | vendorName: 'V1', |
| 43 | vendorId: '97B3E2525E0640ACACF87CE6B3753E80', |
| 44 | category: 'resourceNewCategory.application l4+', |
| 45 | subCategory: 'resourceNewCategory.application l4+.database', |
| 46 | id: 'D4774719D085414E9D5642D1ACD59D20', |
| 47 | version: '0.10', |
| 48 | viewableVersions: ['0.1', '0.2'], |
| 49 | status: versionStatusEnum.CHECK_OUT_STATUS, |
| 50 | lockingUser: 'cs0008' |
| 51 | }; |
| 52 | const atTree = { |
| 53 | 'children': [ |
| 54 | { |
| 55 | 'name': 'HEAT', |
| 56 | 'expanded': true, |
| 57 | 'type': 'heat', |
| 58 | 'children': [ |
| 59 | { |
| 60 | 'name': 'heat_zxeyCtMHhf2.yaml', |
| 61 | 'expanded': true, |
| 62 | 'type': 'heat', |
| 63 | 'errors': [ |
| 64 | { |
| 65 | 'level': 'WARNING', |
| 66 | 'message': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4' |
| 67 | } |
| 68 | ], |
| 69 | 'children': [ |
| 70 | { |
| 71 | 'name': 'heat_env_zxeyCtMHhf2.env', |
| 72 | 'type': 'env' |
| 73 | } |
| 74 | ] |
| 75 | } |
| 76 | ] |
| 77 | } |
| 78 | ] |
| 79 | }; |
| 80 | const errorList = [ |
| 81 | { |
| 82 | 'errorLevel': 'WARNING', |
| 83 | 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4', |
| 84 | 'name': 'heat_zxeyCtMHhf2.yaml', |
| 85 | 'hasParent': false, |
| 86 | 'parentName': 'HEAT', |
| 87 | 'type': 'heat' |
| 88 | }, |
| 89 | { |
| 90 | 'errorLevel': 'WARNING', |
| 91 | 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_3', |
| 92 | 'name': 'heat_zxeyCtMHhf2.yaml', |
| 93 | 'hasParent': false, |
| 94 | 'parentName': 'HEAT', |
| 95 | 'type': 'heat' |
| 96 | } |
| 97 | ]; |
| 98 | |
| 99 | var obj = { |
| 100 | softwareProduct: { |
| 101 | softwareProductEditor: { |
| 102 | data:currentSoftwareProduct |
| 103 | }, softwareProductAttachments: |
| 104 | { |
| 105 | attachmentsTree: atTree, |
| 106 | errorList: errorList |
| 107 | } |
| 108 | } |
| 109 | }; |
| 110 | |
| 111 | var results = mapStateToProps(obj); |
| 112 | expect(results.attachmentsTree).toExist(); |
| 113 | expect(results.errorList).toExist(); |
| 114 | expect(results.hoveredNode).toBe(undefined); |
| 115 | expect(results.selectedNode).toBe(undefined); |
| 116 | }); |
| 117 | |
| 118 | |
| 119 | it('function does exist', () => { |
| 120 | |
| 121 | const currentSoftwareProduct = { |
| 122 | name: 'VSp', |
| 123 | description: 'dfdf', |
| 124 | vendorName: 'V1', |
| 125 | vendorId: '97B3E2525E0640ACACF87CE6B3753E80', |
| 126 | category: 'resourceNewCategory.application l4+', |
| 127 | subCategory: 'resourceNewCategory.application l4+.database', |
| 128 | id: 'D4774719D085414E9D5642D1ACD59D20', |
| 129 | version: '0.10', |
| 130 | viewableVersions: ['0.1', '0.2'], |
| 131 | status: versionStatusEnum.CHECK_OUT_STATUS, |
| 132 | lockingUser: 'cs0008' |
| 133 | }; |
| 134 | const versionControllerData = { |
| 135 | version: currentSoftwareProduct.version, |
| 136 | viewableVersions:currentSoftwareProduct.viewableVersions, |
| 137 | status: currentSoftwareProduct.status, |
| 138 | isCheckedOut: true |
| 139 | }; |
| 140 | const atTree = { |
| 141 | 'children': [ |
| 142 | { |
| 143 | 'name': 'HEAT', |
| 144 | 'expanded': true, |
| 145 | 'type': 'heat', |
| 146 | 'children': [ |
| 147 | { |
| 148 | 'name': 'heat_zxeyCtMHhf2.yaml', |
| 149 | 'expanded': true, |
| 150 | 'type': 'heat', |
| 151 | 'errors': [ |
| 152 | { |
| 153 | 'level': 'WARNING', |
| 154 | 'message': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4' |
| 155 | } |
| 156 | ], |
| 157 | 'children': [ |
| 158 | { |
| 159 | 'name': 'heat_env_zxeyCtMHhf2.env', |
| 160 | 'type': 'env' |
| 161 | } |
| 162 | ] |
| 163 | } |
| 164 | ] |
| 165 | } |
| 166 | ] |
| 167 | }; |
| 168 | const errorList = [ |
| 169 | { |
| 170 | 'errorLevel': 'WARNING', |
| 171 | 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4', |
| 172 | 'name': 'heat_zxeyCtMHhf2.yaml', |
| 173 | 'hasParent': false, |
| 174 | 'parentName': 'HEAT', |
| 175 | 'type': 'heat' |
| 176 | }, |
| 177 | { |
| 178 | 'errorLevel': 'WARNING', |
| 179 | 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_3', |
| 180 | 'name': 'heat_zxeyCtMHhf2.yaml', |
| 181 | 'hasParent': false, |
| 182 | 'parentName': 'HEAT', |
| 183 | 'type': 'heat' |
| 184 | } |
| 185 | ]; |
| 186 | |
| 187 | |
| 188 | var renderer = TestUtils.createRenderer(); |
| 189 | renderer.render(<SoftwareProductAttachmentsView |
| 190 | versionControllerData={versionControllerData} |
| 191 | currentSoftwareProduct={currentSoftwareProduct} |
| 192 | attachmentsTree={atTree} |
| 193 | errorList={errorList}/>); |
| 194 | var renderedOutput = renderer.getRenderOutput(); |
| 195 | expect(renderedOutput).toExist(); |
| 196 | }); |
| 197 | |
| 198 | }); |