79b041cc2df88f74a8678efd95683fcf465be5d6
[sdc.git] / openecomp-ui / test / softwareProduct / deployment / SoftwareProductDeploymentEditor.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 import React from 'react';
17 import ShallowRenderer from 'react-test-renderer/shallow';
18 import TestUtils from 'react-dom/test-utils';
19 import { mapStateToProps }  from 'sdc-app/onboarding/softwareProduct/deployment/editor/SoftwareProductDeploymentEditor.js';
20 import SoftwareProductDeploymentEditorView from 'sdc-app/onboarding/softwareProduct/deployment/editor/SoftwareProductDeploymentEditorView.jsx';
21 import { VSPComponentsFactory } from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js';
22 import { VSPEditorFactoryWithLicensingData } from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
23 import { FeatureGroupStoreFactory } from 'test-utils/factories/licenseModel/FeatureGroupFactories.js';
24 import CurrentScreenFactory from 'test-utils/factories/common/CurrentScreenFactory.js';
25
26 describe('Software Product Deployment Editor Module Tests', function () {
27
28         it('should mapper exist', () => {
29                 expect(mapStateToProps).toBeTruthy();
30         });
31
32         it('should return empty data', () => {
33
34                 const currentSoftwareProduct = VSPEditorFactoryWithLicensingData.build();
35                 const componentsList = VSPComponentsFactory.buildList(1);
36                 const featureGroupsList = FeatureGroupStoreFactory.buildList(2);
37                 const currentScreen = CurrentScreenFactory.build();
38
39                 var state = {
40                         currentScreen,
41                         softwareProduct: {
42                                 softwareProductEditor: {
43                                         data: currentSoftwareProduct
44                                 },
45                                 softwareProductDeployment:
46                                 {
47                                         deploymentFlavors: [],
48                                         deploymentFlavorEditor: {data: {}}
49                                 },
50                                 softwareProductComponents: {
51                                         componentsList,
52                                         computeFlavor: {
53                                                 computesList: []
54                                         }
55                                 }
56                         },
57                         licenseModel: {
58                                 featureGroup: {
59                                         featureGroupsList
60                                 }
61                         }
62                 };
63
64                 var results = mapStateToProps(state);
65                 expect(results.data).toEqual({});
66         });
67
68         it('jsx view test', () => {
69                 const componentsList = VSPComponentsFactory.buildList(1);
70                 const renderer = new ShallowRenderer();
71                 renderer.render(
72                         <SoftwareProductDeploymentEditorView
73                                 isReadOnlyMode={true}
74                                 selectedFeatureGroupsList={[]}
75                                 componentsList={componentsList}
76                                 data={{}}
77                                 onDataChanged={() => {}}
78                                 onSubmit={() => {}}
79                                 onClose={() => {}}/>
80                         );
81                 var renderedOutput = renderer.getRenderOutput();
82                 expect(renderedOutput).toBeTruthy();
83         });
84
85 });