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