[SDC] Onboarding 1710 rebase.
[sdc.git] / openecomp-ui / test / softwareProduct / components / compute / SoftwareProductComponentComputeEditor.test.js
1 /*!
2  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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
13  * or implied. See the License for the specific language governing
14  * permissions and limitations under the License.
15  */
16 import React from 'react';
17 import TestUtils from 'react-addons-test-utils';
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
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                         softwareProduct: SoftwareProductFactory.build({
37                                 softwareProductEditor: {
38                                         data: currentSoftwareProduct
39                                 },
40                                 softwareProductComponents: {
41                                         computeFlavor: {
42                                                 computeEditor: {
43                                                         data: {},
44                                                         qdata: {},
45                                                         qgenericFieldInfo: {},
46                                                         dataMap: {},
47                                                         genericFieldInfo: {},
48                                                         formReady: true
49                                                 }
50                                         }
51                                 }
52                         })
53                 };
54
55                 var results = computeEditorMapStateToProps(obj);
56                 expect(results.data).toBeTruthy();
57                 expect(results.qdata).toBeTruthy();
58                 expect(results.qgenericFieldInfo).toBeTruthy();
59                 expect(results.dataMap).toBeTruthy();
60                 expect(results.genericFieldInfo).toBeTruthy();
61                 expect(results.isReadOnlyMode).toBeTruthy();
62                 expect(results.isFormValid).toBeTruthy();
63                 expect(results.formReady).toBeTruthy();
64         });
65
66         it('Compute Editor - View Test', () => {
67
68                 const props = {
69                         data: ComputeFlavorBaseData.build(),
70                         qdata: ComputeFlavorQData.build(),
71                         dataMap: VSPComponentsComputeDataMapFactory.build(),
72                         isReadOnlyMode: false,
73                         onDataChanged: () => {},
74                         onQDataChanged: () => {},
75                         onSubmit: () => {},
76                         onCancel: () => {}
77                 };
78
79                 var renderer = TestUtils.createRenderer();
80                 renderer.render(<ComputeEditorView {...props}/>);
81                 var renderedOutput = renderer.getRenderOutput();
82                 expect(renderedOutput).toBeTruthy();
83
84         });
85 });