f67389764e0dda881129e7977ebe3a7a07bb396c
[sdc.git] / openecomp-ui / test / softwareProduct / components / compute / SoftwareProductComponentComputeEditor.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 as computeEditorMapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/ComputeFlavorEditor.js';
19 import ComputeEditorView from 'sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/ComputeFlavorEditorView.jsx';
20
21 import {SoftwareProductFactory} from 'test-utils/factories/softwareProduct/SoftwareProductFactory.js';
22 import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
23 import {ComputeFlavorBaseData, ComputeFlavorQData, VSPComponentsComputeDataMapFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsComputeFactory.js';
24 import CurrentScreenFactory from 'test-utils/factories/common/CurrentScreenFactory.js';
25
26 describe('Software Product Component Compute-Editor Mapper and View Classes.', () => {
27
28         it('Compute Editor - mapStateToProps mapper exists', () => {
29                 expect(computeEditorMapStateToProps).toBeTruthy();
30         });
31
32         it('Compute Editor - mapStateToProps data test', () => {
33                 const currentSoftwareProduct = VSPEditorFactory.build();
34
35                 var obj = {
36                         currentScreen: CurrentScreenFactory.build(),
37                         softwareProduct: SoftwareProductFactory.build({
38                                 softwareProductEditor: {
39                                         data: currentSoftwareProduct
40                                 },
41                                 softwareProductComponents: {
42                                         computeFlavor: {
43                                                 computeEditor: {
44                                                         data: {},
45                                                         qdata: {},
46                                                         qgenericFieldInfo: {},
47                                                         dataMap: {},
48                                                         genericFieldInfo: {},
49                                                         formReady: true
50                                                 }
51                                         }
52                                 }
53                         })
54                 };
55
56                 var results = computeEditorMapStateToProps(obj);
57                 expect(results.data).toBeTruthy();
58                 expect(results.qdata).toBeTruthy();
59                 expect(results.qgenericFieldInfo).toBeTruthy();
60                 expect(results.dataMap).toBeTruthy();
61                 expect(results.genericFieldInfo).toBeTruthy();
62                 expect(results.isReadOnlyMode).toBe(false);
63                 expect(results.isFormValid).toBeTruthy();
64                 expect(results.formReady).toBeTruthy();
65         });
66
67         it('Compute Editor - View Test', () => {
68
69                 const props = {
70                         data: ComputeFlavorBaseData.build(),
71                         qdata: ComputeFlavorQData.build(),
72                         dataMap: VSPComponentsComputeDataMapFactory.build(),
73                         isReadOnlyMode: false,
74                         onDataChanged: () => {},
75                         onQDataChanged: () => {},
76                         onSubmit: () => {},
77                         onCancel: () => {}
78                 };
79
80                 const renderer = new ShallowRenderer();
81                 renderer.render(<ComputeEditorView {...props}/>);
82                 var renderedOutput = renderer.getRenderOutput();
83                 expect(renderedOutput).toBeTruthy();
84
85         });
86 });