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