Vodafone | 804ec68 | 2019-03-18 15:46:53 +0530 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | import React from 'react'; |
| 18 | import { mapStateToProps } from 'sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputs.js'; |
| 19 | |
| 20 | import VspValidationInputsView from 'sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputsView.jsx'; |
| 21 | import TestUtils from 'react-dom/test-utils'; |
| 22 | |
| 23 | import { VSPComplianceCheckedFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; |
| 24 | import { VSPCertificationCheckedFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; |
| 25 | import { VSPChecksFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; |
| 26 | import { VSPTestsMapFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; |
| 27 | import { VSPTestsRequestFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; |
| 28 | import { VSPGeneralInfoFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; |
| 29 | |
| 30 | describe('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 | }); |