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 { mapStateToProps } from 'sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputs.js';
20 import VspValidationInputsView from 'sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputsView.jsx';
21 import TestUtils from 'react-dom/test-utils';
22 import { storeCreator } from 'sdc-app/AppStore.js';
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 { VSPTestsMapFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
28 import { VSPTestsRequestFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
29 import { VSPGeneralInfoFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
30 import { mapActionsToProps } from 'sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidation.js';
32 describe('SoftwareProductValidation Mapper and View Classes', () => {
33 it('mapStateToProps mapper exists', () => {
34 expect(mapStateToProps).toBeTruthy();
37 it('mapStateToProps data test', () => {
38 const vspChecksList = VSPChecksFactory.build();
39 const vspTestsMap = VSPTestsMapFactory.build();
40 const certificationChecked = VSPCertificationCheckedFactory.build();
41 const complianceChecked = VSPComplianceCheckedFactory.build();
42 const generalInfo = VSPGeneralInfoFactory.build();
45 softwareProductValidation: {
46 vspChecks: vspChecksList,
47 vspTestsMap: vspTestsMap.vspTestsMap,
49 certificationChecked.certificationChecked,
50 complianceChecked: complianceChecked.complianceChecked,
51 generalInfo: generalInfo.generalInfo
55 var results = mapStateToProps(obj);
56 expect(results.softwareProductValidation.vspChecks).toBeTruthy();
57 expect(results.softwareProductValidation.vspTestsMap).toBeTruthy();
59 results.softwareProductValidation.certificationChecked
62 results.softwareProductValidation.complianceChecked
66 it('SoftwareProductValidationInputView render test', () => {
67 const complianceChecked = VSPComplianceCheckedFactory.build();
68 const certificationChecked = VSPCertificationCheckedFactory.build();
69 const vspTestsMap = VSPTestsMapFactory.build();
70 const vspChecksList = VSPChecksFactory.build();
71 const testsRequest = VSPTestsRequestFactory.build();
72 const generalInfo = VSPGeneralInfoFactory.build();
77 const softwareProductId = '1234';
78 const status = 'draft';
83 softwareProductId: softwareProductId,
85 softwareProductValidation: {
86 complianceChecked: complianceChecked.complianceChecked,
88 certificationChecked.certificationChecked,
89 vspTestsMap: vspTestsMap.vspTestsMap,
90 vspChecks: vspChecksList,
91 testsRequest: testsRequest.testsRequest,
92 generalInfo: generalInfo.generalInfo
96 const store = storeCreator();
97 let dispatch = store.dispatch;
98 let props = Object.assign(
100 mapStateToProps(obj),
101 mapActionsToProps(dispatch)
104 let vspValidationInputView = TestUtils.renderIntoDocument(
105 <VspValidationInputsView {...props} />
107 expect(vspValidationInputView).toBeTruthy();
109 let inputForm = TestUtils.findRenderedDOMComponentWithTag(
110 vspValidationInputView,
113 expect(inputForm).toBeTruthy();
114 TestUtils.Simulate.submit(inputForm);