ff0371ab4fe2d9972469334e80b49e7e84100ea1
[sdc.git] / openecomp-ui / test / softwareProduct / components / network / SoftwareProductComponentsNICEditor.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 TestUtils from 'react-dom/test-utils';
20 import {mapStateToProps}  from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICEditor.js';
21 import SoftwareProductComponentsNICEditorView from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICEditorView.jsx';
22
23 import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
24 import {SoftwareProductFactory} from 'test-utils/factories/softwareProduct/SoftwareProductFactory.js';
25 import {VSPComponentsNicFactory, VSPComponentsNetworkQDataFactory, VSPComponentsNicFactoryQGenericFieldInfo,
26         VSPComponentsNicFactoryGenericFieldInfo, VSPComponentsNetworkDataMapFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js';
27 import CurrentScreenFactory from 'test-utils/factories/common/CurrentScreenFactory.js';
28
29
30 describe('Software Product Component Network NIC Editor and View Classes', () => {
31         it('mapStateToProps mapper exists', () => {
32                 expect(mapStateToProps).toBeTruthy();
33         });
34
35
36         it('mapStateToProps data test', () => {
37
38                 const currentSoftwareProduct = VSPEditorFactory.build();
39
40                 var obj = {
41                         currentScreen: CurrentScreenFactory.build(),
42                         softwareProduct: SoftwareProductFactory.build({
43                                 softwareProductEditor: {
44                                         data: currentSoftwareProduct
45                                 },
46                                 softwareProductComponents: {
47                                         network: {
48                                                 nicEditor: {
49                                                         data: {},
50                                                         qdata: {},
51                                                         dataMap: {},
52                                                         qgenericFieldInfo: {},
53                                                         genericFieldInfo: {}
54                                                 }
55                                         }
56                                 }
57                         })
58                 };
59
60                 var results = mapStateToProps(obj);
61                 expect(results.isReadOnlyMode).toBe(false);
62                 expect(results.currentSoftwareProduct).toBeTruthy();
63                 expect(results.qdata).toBeTruthy();
64                 expect(results.dataMap).toBeTruthy();
65                 expect(results.genericFieldInfo).toBeTruthy();
66                 expect(results.qgenericFieldInfo).toBeTruthy();
67                 expect(results.data).toBeTruthy();
68
69         });
70
71
72         it('Software Product Component Network NIC Editor View Test', () => {
73
74                 const props = {
75                         data: VSPComponentsNicFactory.build(),
76                         qdata: VSPComponentsNetworkQDataFactory.build(),
77                         dataMap: VSPComponentsNetworkDataMapFactory.build(),
78                         genericFieldInfo: VSPComponentsNicFactoryGenericFieldInfo.build(),
79                         qgenericFieldInfo: VSPComponentsNicFactoryQGenericFieldInfo.build(),
80                         isFormValid: true,
81                         formReady: false,
82                         protocols: []
83                 };
84
85                 const renderer = new ShallowRenderer();
86                 renderer.render(<SoftwareProductComponentsNICEditorView {...props}/>);
87                 var renderedOutput = renderer.getRenderOutput();
88                 expect(renderedOutput).toBeTruthy();
89
90         });
91 });