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'; |
Vodafone | 1875093 | 2019-04-05 15:49:06 +0530 | [diff] [blame] | 22 | import { storeCreator } from 'sdc-app/AppStore.js'; |
Vodafone | 804ec68 | 2019-03-18 15:46:53 +0530 | [diff] [blame] | 23 | |
| 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'; |
Vodafone | 1875093 | 2019-04-05 15:49:06 +0530 | [diff] [blame] | 30 | import { mapActionsToProps } from 'sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidation.js'; |
Vodafone | 804ec68 | 2019-03-18 15:46:53 +0530 | [diff] [blame] | 31 | |
| 32 | describe('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 = { |
Vodafone | 1875093 | 2019-04-05 15:49:06 +0530 | [diff] [blame] | 81 | 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 | } |
Vodafone | 804ec68 | 2019-03-18 15:46:53 +0530 | [diff] [blame] | 94 | } |
| 95 | }; |
Vodafone | 1875093 | 2019-04-05 15:49:06 +0530 | [diff] [blame] | 96 | const store = storeCreator(); |
| 97 | let dispatch = store.dispatch; |
| 98 | let props = Object.assign( |
| 99 | {}, |
| 100 | mapStateToProps(obj), |
| 101 | mapActionsToProps(dispatch) |
| 102 | ); |
Vodafone | 804ec68 | 2019-03-18 15:46:53 +0530 | [diff] [blame] | 103 | |
| 104 | let vspValidationInputView = TestUtils.renderIntoDocument( |
Vodafone | 1875093 | 2019-04-05 15:49:06 +0530 | [diff] [blame] | 105 | <VspValidationInputsView {...props} /> |
Vodafone | 804ec68 | 2019-03-18 15:46:53 +0530 | [diff] [blame] | 106 | ); |
| 107 | expect(vspValidationInputView).toBeTruthy(); |
Vodafone | 1875093 | 2019-04-05 15:49:06 +0530 | [diff] [blame] | 108 | |
| 109 | let inputForm = TestUtils.findRenderedDOMComponentWithTag( |
| 110 | vspValidationInputView, |
| 111 | 'form' |
| 112 | ); |
| 113 | expect(inputForm).toBeTruthy(); |
| 114 | TestUtils.Simulate.submit(inputForm); |
Vodafone | 804ec68 | 2019-03-18 15:46:53 +0530 | [diff] [blame] | 115 | }); |
| 116 | }); |