129bd42f23c298ab86068a76d69fa1fbcd6a4561
[sdc.git] / openecomp-ui / test / softwareProduct / components / network / SoftwareProductComponentsNetwork.test.js
1 /*
2  * Copyright © 2016-2017 European Support Limited
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 or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 import React from 'react';
18 import ShallowRenderer from 'react-test-renderer/shallow';
19 import {mapStateToProps}  from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkList.js';
20 import SoftwareProductComponentsNetworkListView from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkListView.jsx';
21
22 import {SoftwareProductFactory} from 'test-utils/factories/softwareProduct/SoftwareProductFactory.js';
23 import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
24 import {VSPComponentsNicWithIdFactory, VSPComponentsVersionControllerFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js';
25
26 describe('Software Product Component Network Mapper and View Classes', () => {
27
28         it('mapStateToProps mapper exists', () => {
29                 expect(mapStateToProps).toBeTruthy();
30         });
31
32         it('mapStateToProps data test', () => {
33
34                 const currentSoftwareProduct = VSPEditorFactory.build();
35
36
37                 var obj = {
38                         softwareProduct: SoftwareProductFactory.build({
39                                 softwareProductEditor: {
40                                         data: currentSoftwareProduct
41                                 },
42                                 softwareProductComponents: {
43                                         componentEditor: {
44                                                 qdata: {},
45                                                 data: {},
46                                                 dataMap: {},
47                                                 qgenericFieldInfo: {},
48                                                 isFormValid: true,
49                                                 formReady: false
50                                         },
51                                         network: {
52                                                 nicEditor: {},
53                                                 nicList: []
54                                         }
55                                 }
56                         })
57                 };
58
59                 var results = mapStateToProps(obj);
60                 expect(results.qdata).toBeTruthy();
61                 expect(results.dataMap).toBeTruthy();
62                 expect(results.qgenericFieldInfo).toBeTruthy();
63                 expect(results.componentData).toBeTruthy();
64         });
65
66         it('Software Product Component Network List View Test', () => {
67
68                 const currentSoftwareProduct = VSPEditorFactory.build();
69
70                 const versionControllerData = VSPComponentsVersionControllerFactory.build();
71
72                 const nicList = VSPComponentsNicWithIdFactory.buildList(1);
73
74                 const renderer = new ShallowRenderer();
75                 renderer.render(
76                         <SoftwareProductComponentsNetworkListView
77                                 versionControllerData={versionControllerData}
78                                 currentSoftwareProduct={currentSoftwareProduct}
79                                 softwareProductId='123'
80                                 componentId='321'
81                                 nicList={nicList}/>);
82                 var renderedOutput = renderer.getRenderOutput();
83                 expect(renderedOutput).toBeTruthy();
84
85
86
87
88         });
89
90 });