[sdc] docker file fix for cassandra
[sdc.git] / openecomp-ui / test / softwareProduct / attachments / SoftwareproductAttachmentsHelper.test.js
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 SoftwareProductAttachmentsActionHelper from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsActionHelper.js';
23 import {storeCreator} from 'sdc-app/AppStore.js';
24 import deepFreeze from 'deep-freeze';
25 import {actionTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js';
26
27
28
29
30
31
32 describe('SoftwareProductAttachments ActionHelper', () => {
33
34         it('function does exist', () => {
35                 expect(SoftwareProductAttachmentsActionHelper).toExist();
36         });
37
38         it('toggleExpanded function check', () => {
39
40
41                 const validationData = {
42                         importStructure: {
43                                 HEAT: [
44                                         {
45                                                 fileName: 'hot-mog-0108-bs1271.yml',
46                                                 env: {
47                                                         fileName: 'hot-mog-0108-bs1271.env'
48                                                 },
49                                                 errors: [
50                                                         {
51                                                                 'level': 'WARNING',
52                                                                 'message': 'Port not bind to any NOVA Server, Resource Id [sm02_port_2]'
53                                                         },
54                                                         {
55                                                                 'level': 'WARNING',
56                                                                 'message': 'Port not bind to any NOVA Server, Resource Id [sm01_port_2]'
57                                                         }
58                                                 ]
59                                         }
60                                 ]
61                         }
62                 };
63
64                 const currentSoftwareProduct = {
65                         name: 'VSp',
66                         description: 'dfdf',
67                         vendorName: 'V1',
68                         vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
69                         category: 'resourceNewCategory.application l4+',
70                         subCategory: 'resourceNewCategory.application l4+.database',
71                         id: 'D4774719D085414E9D5642D1ACD59D20',
72                         version: '0.10',
73                         viewableVersions: ['0.1', '0.2'],
74                         status: 'Locked',
75                         lockingUser: 'cs0008',
76                         validationData
77                 };
78
79
80                 const store = storeCreator();
81                 deepFreeze(store.getState());
82                 deepFreeze(currentSoftwareProduct);
83
84                 store.dispatch({
85                         type:actionTypes.SOFTWARE_PRODUCT_LOADED,
86                         response: currentSoftwareProduct
87                 });
88
89                 expect(store.getState().softwareProduct.softwareProductAttachments.attachmentsTree.children[0].expanded).toBe(true);
90                 SoftwareProductAttachmentsActionHelper.toggleExpanded(store.dispatch, {path:[0]});
91                 expect(store.getState().softwareProduct.softwareProductAttachments.attachmentsTree.children[0].expanded).toBe(false);
92         });
93
94         it('onSelectNode & onUnselectNode function check', () => {
95
96
97                 const validationData = {
98                         importStructure: {
99                                 HEAT: [
100                                         {
101                                                 fileName: 'hot-mog-0108-bs1271.yml',
102                                                 env: {
103                                                         fileName: 'hot-mog-0108-bs1271.env'
104                                                 },
105                                                 errors: [
106                                                         {
107                                                                 'level': 'WARNING',
108                                                                 'message': 'Port not bind to any NOVA Server, Resource Id [sm02_port_2]'
109                                                         },
110                                                         {
111                                                                 'level': 'WARNING',
112                                                                 'message': 'Port not bind to any NOVA Server, Resource Id [sm01_port_2]'
113                                                         }
114                                                 ]
115                                         }
116                                 ]
117                         }
118                 };
119
120                 const currentSoftwareProduct = {
121                         name: 'VSp',
122                         description: 'dfdf',
123                         vendorName: 'V1',
124                         vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
125                         category: 'resourceNewCategory.application l4+',
126                         subCategory: 'resourceNewCategory.application l4+.database',
127                         id: 'D4774719D085414E9D5642D1ACD59D20',
128                         version: '0.10',
129                         viewableVersions: ['0.1', '0.2'],
130                         status: 'Locked',
131                         lockingUser: 'cs0008',
132                         validationData
133                 };
134
135                 deepFreeze(currentSoftwareProduct);
136                 
137                 const store = storeCreator();
138                 deepFreeze(store.getState());
139
140                 store.dispatch({
141                         type:actionTypes.SOFTWARE_PRODUCT_LOADED,
142                         response: currentSoftwareProduct
143                 });
144                 let expectedNodeName = 'name';
145                 expect(store.getState().softwareProduct.softwareProductAttachments.selectedNode).toBe(undefined);
146                 SoftwareProductAttachmentsActionHelper.onSelectNode(store.dispatch, {nodeName:expectedNodeName});
147                 expect(store.getState().softwareProduct.softwareProductAttachments.selectedNode).toBe(expectedNodeName);
148                 SoftwareProductAttachmentsActionHelper.onUnselectNode(store.dispatch);
149                 expect(store.getState().softwareProduct.softwareProductAttachments.selectedNode).toBe(undefined);
150         });
151
152
153 });