2 * Copyright © 2019 Vodafone Group
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 import React from 'react';
18 import { Provider } from 'react-redux';
19 import { storeCreator } from 'sdc-app/AppStore.js';
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';
33 describe('SoftwareProductValidation Mapper and View Classes', () => {
34 it('mapStateToProps mapper exists', () => {
35 expect(mapStateToProps).toBeTruthy();
38 it('mapActionsToProps mapper exists', () => {
39 expect(mapActionsToProps).toBeTruthy();
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();
51 softwareProductValidation: {
52 vspChecks: vspChecksList,
53 vspTestsMap: vspTestsMap.vspTestsMap,
55 certificationChecked.certificationChecked,
56 complianceChecked: complianceChecked.complianceChecked,
57 activeTab: tabsMapping.SETUP,
58 generalInfo: generalInfo.generalInfo
62 var results = mapStateToProps(obj);
63 expect(results.softwareProductValidation.vspChecks).toBeTruthy();
64 expect(results.softwareProductValidation.vspTestsMap).toBeTruthy();
66 results.softwareProductValidation.certificationChecked
69 results.softwareProductValidation.complianceChecked
71 expect(results.softwareProductValidation.activeTab).toBeTruthy();
72 expect(results.softwareProductValidation.generalInfo).toBeTruthy();
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 = () => {};
85 const softwareProductId = '1234';
86 const status = 'draft';
90 softwareProductId: softwareProductId,
92 softwareProductValidation: {
93 vspChecks: vspChecksList,
94 vspTestsMap: vspTestsMap.vspTestsMap,
96 certificationChecked.certificationChecked,
97 complianceChecked: complianceChecked.complianceChecked,
98 activeTab: tabsMapping.SETUP
103 const store = storeCreator();
104 let dispatch = store.dispatch;
106 let props = Object.assign(
108 mapStateToProps(obj),
109 mapActionsToProps(dispatch)
112 let softwareProductValidationView = TestUtils.renderIntoDocument(
113 <Provider store={store}>
114 <SoftwareProductValidationView {...props} />
118 expect(softwareProductValidationView).toBeTruthy();
120 let goToInput = scryRenderedDOMComponentsWithTestId(
121 softwareProductValidationView,
122 'go-to-vsp-validation-inputs'
124 expect(goToInput).toBeTruthy();
125 // TestUtils.Simulate.click(goToInput[0]);
127 // store.getState().softwareProduct.softwareProductValidation.activeTab
128 // ).toBe(tabsMapping.INPUTS);
129 // let goToSetup = scryRenderedDOMComponentsWithTestId(
130 // softwareProductValidationView,
131 // 'go-to-vsp-validation-setup'
133 // expect(goToSetup).toBeTruthy();
134 // TestUtils.Simulate.click(goToSetup[0]);
136 // store.getState().softwareProduct.softwareProductValidation.activeTab
137 // ).toBe(tabsMapping.SETUP);