Add collaboration feature
[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
23 describe('SoftwareProductAttachments Modal Mapper and View Classes', () => {
24
25         it ('mapStateToProps mapper exists', () => {
26                 expect(mapStateToProps).toBeTruthy();
27         });
28
29
30         it ('mapStateToProps check data', () => {
31
32                 const currentSoftwareProduct = {
33                         name: 'VSp',
34                         description: 'dfdf',
35                         vendorName: 'V1',
36                         vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
37                         category: 'resourceNewCategory.application l4+',
38                         subCategory: 'resourceNewCategory.application l4+.database',
39                         id: 'D4774719D085414E9D5642D1ACD59D20',
40                         version: '0.10',
41                         viewableVersions: ['0.1', '0.2'],
42                         lockingUser: 'cs0008'
43                 };
44                 const atTree = {
45                         'children': [
46                                 {
47                                         'name': 'HEAT',
48                                         'expanded': true,
49                                         'type': 'heat',
50                                         'children': [
51                                                 {
52                                                         'name': 'heat_zxeyCtMHhf2.yaml',
53                                                         'expanded': true,
54                                                         'type': 'heat',
55                                                         'errors': [
56                                                                 {
57                                                                         'level': 'WARNING',
58                                                                         'message': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4'
59                                                                 }
60                                                         ],
61                                                         'children': [
62                                                                 {
63                                                                         'name': 'heat_env_zxeyCtMHhf2.env',
64                                                                         'type': 'env'
65                                                                 }
66                                                         ]
67                                                 }
68                                         ]
69                                 }
70                         ]
71                 };
72                 const errorList = [
73                         {
74                                 'errorLevel': 'WARNING',
75                                 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4',
76                                 'name': 'heat_zxeyCtMHhf2.yaml',
77                                 'hasParent': false,
78                                 'parentName': 'HEAT',
79                                 'type': 'heat'
80                         },
81                         {
82                                 'errorLevel': 'WARNING',
83                                 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_3',
84                                 'name': 'heat_zxeyCtMHhf2.yaml',
85                                 'hasParent': false,
86                                 'parentName': 'HEAT',
87                                 'type': 'heat'
88                         }
89                 ];
90
91                 var obj = {
92                         softwareProduct: {
93                                 softwareProductEditor: {
94                                         data:currentSoftwareProduct
95                                 }, softwareProductAttachments:
96                                 {
97                                         heatValidation: {
98                                                 attachmentsTree: atTree,
99                                                 errorList: errorList
100                                         }
101                                 }
102                         }
103                 };
104
105                 var results = mapStateToProps(obj);
106                 expect(results.attachmentsTree).toBeTruthy();
107                 expect(results.errorList).toBeTruthy();
108                 expect(results.currentErrors).toBeTruthy();
109                 expect(results.currentWarnings).toBeTruthy();
110                 expect(results.selectedNode).toBe(undefined);
111         });
112
113
114         it('function does exist', () => {
115
116                 const atTree = {
117                         'children': [
118                                 {
119                                         'name': 'HEAT',
120                                         'expanded': true,
121                                         'type': 'heat',
122                                         'children': [
123                                                 {
124                                                         'name': 'heat_zxeyCtMHhf2.yaml',
125                                                         'expanded': true,
126                                                         'type': 'heat',
127                                                         'errors': [
128                                                                 {
129                                                                         'level': 'WARNING',
130                                                                         'message': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4'
131                                                                 }
132                                                         ],
133                                                         'children': [
134                                                                 {
135                                                                         'name': 'heat_env_zxeyCtMHhf2.env',
136                                                                         'type': 'env'
137                                                                 }
138                                                         ]
139                                                 }
140                                         ]
141                                 }
142                         ]
143                 };
144                 const errorList = [
145                         {
146                                 'errorLevel': 'WARNING',
147                                 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4',
148                                 'name': 'heat_zxeyCtMHhf2.yaml',
149                                 'hasParent': false,
150                                 'parentName': 'HEAT',
151                                 'type': 'heat'
152                         },
153                         {
154                                 'errorLevel': 'WARNING',
155                                 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_3',
156                                 'name': 'heat_zxeyCtMHhf2.yaml',
157                                 'hasParent': false,
158                                 'parentName': 'HEAT',
159                                 'type': 'heat'
160                         }
161                 ];
162                 var currentErrors = [];
163                 var currentWarnings = [];
164                 var onSelect = () => { return null; } ;
165                 var onDeSelect = () => { return null; } ;
166                 var onToggle = () => { return null; } ;
167
168                 var renderer = TestUtils.createRenderer();
169                 renderer.render(<HeatValidationView
170                         attachmentsTree={atTree}
171                         errorList={errorList}
172                         currentWarnings={currentWarnings}
173                         currentErrors={currentErrors}
174                         onSelectNode={onSelect}
175                         onDeselectNode={onDeSelect}
176                         toggleExpanded = {onToggle} />);
177                 var renderedOutput = renderer.getRenderOutput();
178                 expect(renderedOutput).toBeTruthy();
179         });
180
181 });