5a4dc61cbcd4daaed5c592dc6e750e1450ef4016
[sdc.git] / openecomp-ui / test / softwareProduct / components / processes / SoftwareProductComponentsProcessesView.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 {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesList.js';
20 import SoftwareProductComponentsProcessesView from 'sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentsProcessesListView.jsx';
21
22 import {VSPProcessStoreFactory} from 'test-utils/factories/softwareProduct/SoftwareProductProcessFactories.js';
23 import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
24 import {VSPComponentsFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js';
25
26 describe('SoftwareProductComponetsProcesses Mapper and View Classes', () => {
27         it('mapStateToProps mapper exists', () => {             
28                 expect(mapStateToProps).toBeTruthy();
29         });
30
31         it('mapStateToProps data test', () => {         
32                 const currentSoftwareProduct = VSPEditorFactory.build();
33
34                 const processesList = VSPProcessStoreFactory.buildList(2);
35
36                 var state = {
37                         softwareProduct: {
38                                 softwareProductEditor: {
39                                         data: currentSoftwareProduct
40                                 },
41                                 softwareProductComponents: {
42                                         componentProcesses: {
43                                                 processesList,
44                                                 processesEditor: {
45                                                         data: {}
46                                                 }
47                                         }
48                                 }
49                         }
50                 };
51                 var results = mapStateToProps(state);
52                 expect(results.processesList.length).toBe(2);
53         });
54
55         it('view simple test', () => {          
56                 const currentSoftwareProduct = VSPEditorFactory.build();
57                 const currentSoftwareProductComponent = VSPComponentsFactory.build();
58                 const processesList = VSPProcessStoreFactory.buildList(2);
59
60                 const renderer = new ShallowRenderer();
61                 renderer.render(
62                         <SoftwareProductComponentsProcessesView
63                                 processesList={processesList}
64                                 currentSoftwareProduct={currentSoftwareProduct}
65                                 softwareProductId={currentSoftwareProduct.id}
66                                 componentId={currentSoftwareProductComponent.id}
67                                 onAddProcess={() => {}}
68                                 onEditProcess={() => {}}
69                                 onDeleteProcess={() => {}}
70                                 isDisplayEditor={false}
71                                 isReadOnlyMode={false}/>
72                         );
73                 var renderedOutput = renderer.getRenderOutput();
74                 expect(renderedOutput).toBeTruthy();
75         });
76 });