react-version-downgrade
[sdc.git] / openecomp-ui / test / softwareProduct / components / general / SoftwareProductComponentsGeneral.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 TestUtils from 'react-addons-test-utils';
19 import {mapStateToProps}  from 'sdc-app/onboarding/softwareProduct/components/general/SoftwareProductComponentsGeneral.js';
20 import SoftwareProductComponentsGeneralView from 'sdc-app/onboarding/softwareProduct/components/general/SoftwareProductComponentsGeneralView.jsx';
21 //import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
22
23 import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
24 import {VSPComponentsVersionControllerFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js';
25 import {SoftwareProductFactory} from 'test-utils/factories/softwareProduct/SoftwareProductFactory.js';
26 import VSPQSchemaFactory from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js';
27
28
29 describe('SoftwareProductComponentsGeneral Mapper and View Classes', () => {
30         it('mapStateToProps mapper exists', () => {
31                 expect(mapStateToProps).toBeTruthy();
32         });
33
34         it('mapStateToProps data test', () => {
35
36                 const currentSoftwareProduct = VSPEditorFactory.build();
37
38                 var obj = {
39                         softwareProduct: SoftwareProductFactory.build({
40                                 softwareProductEditor: {
41                                         data: currentSoftwareProduct
42                                 },
43                                 softwareProductComponents: {
44                                         componentEditor: {
45                                                 data: {},
46                                                 qdata: {}
47                                         }
48                                 }
49                         })
50                 };
51
52                 var results = mapStateToProps(obj);
53                 expect(results.componentData).toBeTruthy();
54                 expect(results.qdata).toBeTruthy();
55         });
56
57
58         it('VSP Components general view test', () => {
59
60                 const currentSoftwareProduct = VSPEditorFactory.build();
61
62                 const softwareProductComponents = {
63                         componentEditor: {
64                                 data: {},
65                                 qdata: {},
66                                 qschema: VSPQSchemaFactory.build()
67                         }
68                 };
69
70                 const versionControllerData = VSPComponentsVersionControllerFactory.build();
71
72                 const componentData = {
73                         name: ''
74                 };
75
76                 var renderer = TestUtils.createRenderer();
77                 renderer.render(
78                         <SoftwareProductComponentsGeneralView
79                                 componentData={componentData}
80                                 softwareProductComponents={softwareProductComponents}
81                                 versionControllerData={versionControllerData}
82                                 currentSoftwareProduct={currentSoftwareProduct}/>);
83                 var renderedOutput = renderer.getRenderOutput();
84                 expect(renderedOutput).toBeTruthy();
85
86         });
87
88 });