4b7f8464baa3eea0eb8605625f14e73fc7acda32
[sdc.git] / openecomp-ui / test / softwareProduct / deployment / SoftwareProductDeploymentView.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 {mapStateToProps}  from 'sdc-app/onboarding/softwareProduct/deployment/SoftwareProductDeployment.js';
19 import SoftwareProductDeploymentView from 'sdc-app/onboarding/softwareProduct/deployment/SoftwareProductDeploymentView.jsx';
20
21 import {VSPDeploymentStoreFactory} from 'test-utils/factories/softwareProduct/SoftwareProductDeploymentFactories.js';
22 import {VSPComponentsFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js';
23 import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
24
25 describe('SoftwareProductDeployment Mapper and View Classes', () => {
26         it ('mapStateToProps mapper exists', () => {
27                 expect(mapStateToProps).toBeTruthy();
28         });
29
30         it ('mapStateToProps data test', () => {
31
32                 const currentSoftwareProduct = VSPEditorFactory.build();
33
34                 const deploymentFlavors =   VSPDeploymentStoreFactory.buildList(2);
35
36                 const componentsList = VSPComponentsFactory.buildList(1);
37
38                 var state = {
39                         softwareProduct: {
40                                 softwareProductEditor: {
41                                         data: currentSoftwareProduct
42                                 },
43                                 softwareProductDeployment:
44                                 {
45                                         deploymentFlavors,
46                                         deploymentFlavorsEditor: {data: {}}
47                                 },
48                                 softwareProductComponents: {
49                                         componentsList
50                                 }
51                         }
52                 };
53                 var results = mapStateToProps(state);
54                 expect(results.deploymentFlavors).toBeTruthy();
55         });
56
57         it ('view simple test', () => {
58
59                 const currentSoftwareProduct = VSPEditorFactory.build();
60
61                 const deploymentFlavors = VSPDeploymentStoreFactory.buildList(2);
62
63                 const renderer = new ShallowRenderer();
64                 renderer.render(
65                         <SoftwareProductDeploymentView
66                                 deploymentFlavors={deploymentFlavors}
67                                 currentSoftwareProduct={currentSoftwareProduct}
68                                 onAddDeployment={() => {}}
69                                 onEditDeployment={() => {}}
70                                 onDeleteDeployment={() => {}}
71                                 isReadOnlyMode={false} />
72                         );
73                 var renderedOutput = renderer.getRenderOutput();
74                 expect(renderedOutput).toBeTruthy();
75
76         });
77 });