blob: 68a8cdd957916fac5efefea7358c56d314b993cd [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 { mapStateToProps } from 'sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputs.js';
19
20import VspValidationInputsView from 'sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputsView.jsx';
21import TestUtils from 'react-dom/test-utils';
Vodafone18750932019-04-05 15:49:06 +053022import { storeCreator } from 'sdc-app/AppStore.js';
Vodafone804ec682019-03-18 15:46:53 +053023
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 { VSPTestsRequestFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
29import { VSPGeneralInfoFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
Vodafone18750932019-04-05 15:49:06 +053030import { mapActionsToProps } from 'sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidation.js';
Vodafone804ec682019-03-18 15:46:53 +053031
32describe('SoftwareProductValidation Mapper and View Classes', () => {
33 it('mapStateToProps mapper exists', () => {
34 expect(mapStateToProps).toBeTruthy();
35 });
36
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();
43 var obj = {
44 softwareProduct: {
45 softwareProductValidation: {
46 vspChecks: vspChecksList,
47 vspTestsMap: vspTestsMap.vspTestsMap,
48 certificationChecked:
49 certificationChecked.certificationChecked,
50 complianceChecked: complianceChecked.complianceChecked,
51 generalInfo: generalInfo.generalInfo
52 }
53 }
54 };
55 var results = mapStateToProps(obj);
56 expect(results.softwareProductValidation.vspChecks).toBeTruthy();
57 expect(results.softwareProductValidation.vspTestsMap).toBeTruthy();
58 expect(
59 results.softwareProductValidation.certificationChecked
60 ).toBeTruthy();
61 expect(
62 results.softwareProductValidation.complianceChecked
63 ).toBeTruthy();
64 });
65
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();
73
74 const version = {
75 name: 1
76 };
77 const softwareProductId = '1234';
78 const status = 'draft';
79
80 var obj = {
Vodafone18750932019-04-05 15:49:06 +053081 softwareProduct: {
82 version: version,
83 softwareProductId: softwareProductId,
84 status: status,
85 softwareProductValidation: {
86 complianceChecked: complianceChecked.complianceChecked,
87 certificationChecked:
88 certificationChecked.certificationChecked,
89 vspTestsMap: vspTestsMap.vspTestsMap,
90 vspChecks: vspChecksList,
91 testsRequest: testsRequest.testsRequest,
92 generalInfo: generalInfo.generalInfo
93 }
Vodafone804ec682019-03-18 15:46:53 +053094 }
95 };
Vodafone18750932019-04-05 15:49:06 +053096 const store = storeCreator();
97 let dispatch = store.dispatch;
98 let props = Object.assign(
99 {},
100 mapStateToProps(obj),
101 mapActionsToProps(dispatch)
102 );
Vodafone804ec682019-03-18 15:46:53 +0530103
104 let vspValidationInputView = TestUtils.renderIntoDocument(
Vodafone18750932019-04-05 15:49:06 +0530105 <VspValidationInputsView {...props} />
Vodafone804ec682019-03-18 15:46:53 +0530106 );
107 expect(vspValidationInputView).toBeTruthy();
Vodafone18750932019-04-05 15:49:06 +0530108
109 let inputForm = TestUtils.findRenderedDOMComponentWithTag(
110 vspValidationInputView,
111 'form'
112 );
113 expect(inputForm).toBeTruthy();
114 TestUtils.Simulate.submit(inputForm);
Vodafone804ec682019-03-18 15:46:53 +0530115 });
116});