VSP Compliance Check for Compute Flavor
[sdc.git] / openecomp-ui / test / softwareProduct / validation / SoftwareProductValidationView.test.js
1 /*
2  * Copyright © 2019 Vodafone Group
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 { Provider } from 'react-redux';
19 import { storeCreator } from 'sdc-app/AppStore.js';
20
21 import { mapStateToProps } from 'sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidation.js';
22 import { mapActionsToProps } from 'sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidation.js';
23 import SoftwareProductValidationView from 'sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationView.jsx';
24 import { VSPComplianceCheckedFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
25 import { VSPCertificationCheckedFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
26 import { VSPChecksFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
27 import { VSPGeneralInfoFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
28 import { VSPTestsMapFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
29 import { tabsMapping } from 'sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationConstants.js';
30 import TestUtils from 'react-dom/test-utils';
31 import { scryRenderedDOMComponentsWithTestId } from 'test-utils/Util.js';
32
33 describe('SoftwareProductValidation Mapper and View Classes', () => {
34     it('mapStateToProps mapper exists', () => {
35         expect(mapStateToProps).toBeTruthy();
36     });
37
38     it('mapActionsToProps mapper exists', () => {
39         expect(mapActionsToProps).toBeTruthy();
40     });
41
42     it('mapStateToProps data test', () => {
43         const vspChecksList = VSPChecksFactory.build();
44         const vspTestsMap = VSPTestsMapFactory.build();
45         const certificationChecked = VSPCertificationCheckedFactory.build();
46         const complianceChecked = VSPComplianceCheckedFactory.build();
47         const generalInfo = VSPGeneralInfoFactory.build();
48
49         var obj = {
50             softwareProduct: {
51                 softwareProductValidation: {
52                     vspChecks: vspChecksList,
53                     vspTestsMap: vspTestsMap.vspTestsMap,
54                     certificationChecked:
55                         certificationChecked.certificationChecked,
56                     complianceChecked: complianceChecked.complianceChecked,
57                     activeTab: tabsMapping.SETUP,
58                     generalInfo: generalInfo.generalInfo
59                 }
60             }
61         };
62         var results = mapStateToProps(obj);
63         expect(results.softwareProductValidation.vspChecks).toBeTruthy();
64         expect(results.softwareProductValidation.vspTestsMap).toBeTruthy();
65         expect(
66             results.softwareProductValidation.certificationChecked
67         ).toBeTruthy();
68         expect(
69             results.softwareProductValidation.complianceChecked
70         ).toBeTruthy();
71         expect(results.softwareProductValidation.activeTab).toBeTruthy();
72         expect(results.softwareProductValidation.generalInfo).toBeTruthy();
73     });
74
75     it('SoftwareProductValidationView render test', () => {
76         const vspChecksList = VSPChecksFactory.build();
77         const vspTestsMap = VSPTestsMapFactory.build();
78         const certificationChecked = VSPCertificationCheckedFactory.build();
79         const complianceChecked = VSPComplianceCheckedFactory.build();
80         // let dummyFunc = () => {};
81         const version = {
82             id: 12345,
83             name: 1
84         };
85         const softwareProductId = '1234';
86         const status = 'draft';
87         var obj = {
88             softwareProduct: {
89                 version: version,
90                 softwareProductId: softwareProductId,
91                 status: status,
92                 softwareProductValidation: {
93                     vspChecks: vspChecksList,
94                     vspTestsMap: vspTestsMap.vspTestsMap,
95                     certificationChecked:
96                         certificationChecked.certificationChecked,
97                     complianceChecked: complianceChecked.complianceChecked,
98                     activeTab: tabsMapping.SETUP
99                 }
100             }
101         };
102
103         const store = storeCreator();
104         let dispatch = store.dispatch;
105
106         let props = Object.assign(
107             {},
108             mapStateToProps(obj),
109             mapActionsToProps(dispatch)
110         );
111
112         let softwareProductValidationView = TestUtils.renderIntoDocument(
113             <Provider store={store}>
114                 <SoftwareProductValidationView {...props} />
115             </Provider>
116         );
117
118         expect(softwareProductValidationView).toBeTruthy();
119
120         let goToInput = scryRenderedDOMComponentsWithTestId(
121             softwareProductValidationView,
122             'go-to-vsp-validation-inputs'
123         );
124         expect(goToInput).toBeTruthy();
125         // TestUtils.Simulate.click(goToInput[0]);
126         // expect(
127         //     store.getState().softwareProduct.softwareProductValidation.activeTab
128         // ).toBe(tabsMapping.INPUTS);
129         // let goToSetup = scryRenderedDOMComponentsWithTestId(
130         //     softwareProductValidationView,
131         //     'go-to-vsp-validation-setup'
132         // );
133         // expect(goToSetup).toBeTruthy();
134         // TestUtils.Simulate.click(goToSetup[0]);
135         // expect(
136         //     store.getState().softwareProduct.softwareProductValidation.activeTab
137         // ).toBe(tabsMapping.SETUP);
138     });
139 });