blob: 640f9f64be2cb4457e571e82efd1b187dd93e863 [file] [log] [blame]
Vodafone804ec682019-03-18 15:46:53 +05301/*
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
17import React from 'react';
18import { Provider } from 'react-redux';
19import { storeCreator } from 'sdc-app/AppStore.js';
20
21import { mapStateToProps } from 'sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidation.js';
22import { mapActionsToProps } from 'sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidation.js';
23import SoftwareProductValidationView from 'sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationView.jsx';
24import { VSPComplianceCheckedFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
25import { VSPCertificationCheckedFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
26import { VSPChecksFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
27import { VSPTestsMapFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
28import { tabsMapping } from 'sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationConstants.js';
29import TestUtils from 'react-dom/test-utils';
30//import { scryRenderedDOMComponentsWithTestId } from 'test-utils/Util.js';
31
32describe('SoftwareProductValidation Mapper and View Classes', () => {
33 it('mapStateToProps mapper exists', () => {
34 expect(mapStateToProps).toBeTruthy();
35 });
36
37 it('mapActionsToProps mapper exists', () => {
38 expect(mapActionsToProps).toBeTruthy();
39 });
40
41 it('mapStateToProps data test', () => {
42 const vspChecksList = VSPChecksFactory.build();
43 const vspTestsMap = VSPTestsMapFactory.build();
44 const certificationChecked = VSPCertificationCheckedFactory.build();
45 const complianceChecked = VSPComplianceCheckedFactory.build();
46
47 var obj = {
48 softwareProduct: {
49 softwareProductValidation: {
50 vspChecks: vspChecksList,
51 vspTestsMap: vspTestsMap.vspTestsMap,
52 certificationChecked: certificationChecked.certificationChecked,
53 complianceChecked: complianceChecked.complianceChecked,
54 activeTab: tabsMapping.SETUP
55 }
56 }
57 };
58 var results = mapStateToProps(obj);
59 expect(results.softwareProductValidation.vspChecks).toBeTruthy();
60 expect(results.softwareProductValidation.vspTestsMap).toBeTruthy();
61 expect(
62 results.softwareProductValidation.certificationChecked
63 ).toBeTruthy();
64 expect(
65 results.softwareProductValidation.complianceChecked
66 ).toBeTruthy();
67 expect(results.softwareProductValidation.activeTab).toBeTruthy();
68 });
69
70 it('SoftwareProductValidationView render test', () => {
71 const vspChecksList = VSPChecksFactory.build();
72 const vspTestsMap = VSPTestsMapFactory.build();
73 const certificationChecked = VSPCertificationCheckedFactory.build();
74 const complianceChecked = VSPComplianceCheckedFactory.build();
75 let dummyFunc = () => {};
76 const version = {
77 name: 1
78 };
79 const softwareProductId = '1234';
80 const status = 'draft';
81 var obj = {
82 version: version,
83 softwareProductId: softwareProductId,
84 status: status,
85 softwareProductValidation: {
86 vspChecks: vspChecksList,
87 vspTestsMap: vspTestsMap,
88 certificationChecked: certificationChecked.certificationChecked,
89 complianceChecked: complianceChecked.complianceChecked,
90 activeTab: tabsMapping.SETUP
91 }
92 };
93 const store = storeCreator();
94 let softwareProductValidationView = TestUtils.renderIntoDocument(
95 <Provider store={store}>
96 <SoftwareProductValidationView
97 {...obj}
98 onErrorThrown={dummyFunc}
99 onTestSubmit={dummyFunc}
100 setVspTestsMap={dummyFunc}
101 setActiveTab={dummyFunc}
102 setComplianceChecked={dummyFunc}
103 setCertificationChecked={dummyFunc}
104 />
105 </Provider>
106 );
107
108 expect(softwareProductValidationView).toBeTruthy();
109
110 // let goToInput = scryRenderedDOMComponentsWithTestId(
111 // softwareProductValidationView,
112 // 'go-to-inputs'
113 // );
114 // expect(goToInput).toBeTruthy();
115 // TestUtils.Simulate.click(goToInput[0]);
116 // let goToInput = TestUtils.findRenderedDOMComponentWithClass(
117 // softwareProductValidationView,
118 // 'go-to-inputs-btn'
119 // );
120 // TestUtils.Simulate.click(goToInput);
121 });
122});