blob: aa00a5d605c087f4ad72a2f8e66dc0ff252e9e9f [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';
22
23import { VSPComplianceCheckedFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
24import { VSPCertificationCheckedFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
25import { VSPChecksFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
26import { VSPTestsMapFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
27import { VSPTestsRequestFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
28import { VSPGeneralInfoFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
29
30describe('SoftwareProductValidation Mapper and View Classes', () => {
31 it('mapStateToProps mapper exists', () => {
32 expect(mapStateToProps).toBeTruthy();
33 });
34
35 it('mapStateToProps data test', () => {
36 const vspChecksList = VSPChecksFactory.build();
37 const vspTestsMap = VSPTestsMapFactory.build();
38 const certificationChecked = VSPCertificationCheckedFactory.build();
39 const complianceChecked = VSPComplianceCheckedFactory.build();
40 const generalInfo = VSPGeneralInfoFactory.build();
41 var obj = {
42 softwareProduct: {
43 softwareProductValidation: {
44 vspChecks: vspChecksList,
45 vspTestsMap: vspTestsMap.vspTestsMap,
46 certificationChecked:
47 certificationChecked.certificationChecked,
48 complianceChecked: complianceChecked.complianceChecked,
49 generalInfo: generalInfo.generalInfo
50 }
51 }
52 };
53 var results = mapStateToProps(obj);
54 expect(results.softwareProductValidation.vspChecks).toBeTruthy();
55 expect(results.softwareProductValidation.vspTestsMap).toBeTruthy();
56 expect(
57 results.softwareProductValidation.certificationChecked
58 ).toBeTruthy();
59 expect(
60 results.softwareProductValidation.complianceChecked
61 ).toBeTruthy();
62 });
63
64 it('SoftwareProductValidationInputView render test', () => {
65 const complianceChecked = VSPComplianceCheckedFactory.build();
66 const certificationChecked = VSPCertificationCheckedFactory.build();
67 const vspTestsMap = VSPTestsMapFactory.build();
68 const vspChecksList = VSPChecksFactory.build();
69 const testsRequest = VSPTestsRequestFactory.build();
70 const generalInfo = VSPGeneralInfoFactory.build();
71
72 const version = {
73 name: 1
74 };
75 const softwareProductId = '1234';
76 const status = 'draft';
77
78 var obj = {
79 version: version,
80 softwareProductId: softwareProductId,
81 status: status,
82 softwareProductValidation: {
83 complianceChecked: complianceChecked.complianceChecked,
84 certificationChecked: certificationChecked.certificationChecked,
85 vspTestsMap: vspTestsMap.vspTestsMap,
86 vspChecks: vspChecksList,
87 testsRequest: testsRequest.testsRequest,
88 generalInfo: generalInfo.generalInfo
89 }
90 };
91
92 let vspValidationInputView = TestUtils.renderIntoDocument(
93 <VspValidationInputsView {...obj} />
94 );
95 expect(vspValidationInputView).toBeTruthy();
96 });
97});