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/validationResults/SoftwareProductValidationResults.js'; |
| 19 | import SoftwareProductValidationResultsView from 'sdc-app/onboarding/softwareProduct/validationResults/SoftwareProductValidationResultsView.jsx'; |
| 20 | import { VSPTestResultsSuccessFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js'; |
atulpurohit | 8b34684 | 2019-11-05 14:31:56 +0530 | [diff] [blame] | 21 | import { VSPTestResultKeysFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js'; |
Vodafone | 804ec68 | 2019-03-18 15:46:53 +0530 | [diff] [blame] | 22 | import { VSPTestResultsFailureFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js'; |
Vodafone | 1875093 | 2019-04-05 15:49:06 +0530 | [diff] [blame] | 23 | import { VSPTestsMapFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; |
atulpurohit | 8b34684 | 2019-11-05 14:31:56 +0530 | [diff] [blame] | 24 | import { VSPChecksFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; |
Vodafone | 1875093 | 2019-04-05 15:49:06 +0530 | [diff] [blame] | 25 | |
Vodafone | 804ec68 | 2019-03-18 15:46:53 +0530 | [diff] [blame] | 26 | import TestUtils from 'react-dom/test-utils'; |
| 27 | |
| 28 | describe('SoftwareProductValidationResults Mapper and View Classes', () => { |
atulpurohit | 8b34684 | 2019-11-05 14:31:56 +0530 | [diff] [blame] | 29 | it('mapStateToProps mapper exists', () => { |
Vodafone | 804ec68 | 2019-03-18 15:46:53 +0530 | [diff] [blame] | 30 | expect(mapStateToProps).toBeTruthy(); |
| 31 | }); |
| 32 | |
| 33 | it('mapStateToProps fail data test', () => { |
| 34 | const vspTestResults = VSPTestResultsFailureFactory.build(); |
Vodafone | 1875093 | 2019-04-05 15:49:06 +0530 | [diff] [blame] | 35 | const vspTestsMap = VSPTestsMapFactory.build(); |
atulpurohit | 8b34684 | 2019-11-05 14:31:56 +0530 | [diff] [blame] | 36 | const testResultKeys = VSPTestResultKeysFactory.build(); |
| 37 | const version = { |
| 38 | name: 1 |
| 39 | }; |
| 40 | const softwareProductId = '1234'; |
| 41 | var testResultToDisplay = {}; |
| 42 | var vspIdAndVer = softwareProductId+version.name; |
| 43 | testResultToDisplay[vspIdAndVer] = vspTestResults.vspTestResults; |
| 44 | var testResultKeyByVspId = {}; |
| 45 | testResultKeyByVspId[vspIdAndVer] = testResultKeys.testResultKeys; |
Vodafone | 804ec68 | 2019-03-18 15:46:53 +0530 | [diff] [blame] | 46 | var obj = { |
| 47 | softwareProduct: { |
| 48 | softwareProductValidation: { |
atulpurohit | 8b34684 | 2019-11-05 14:31:56 +0530 | [diff] [blame] | 49 | testResultKeys: testResultKeys.testResultKeys |
| 50 | }, |
| 51 | softwareProductValidationResult: { |
| 52 | testResultToDisplay: testResultToDisplay, |
Vodafone | 804ec68 | 2019-03-18 15:46:53 +0530 | [diff] [blame] | 53 | } |
| 54 | } |
| 55 | }; |
| 56 | var results = mapStateToProps(obj); |
atulpurohit | 8b34684 | 2019-11-05 14:31:56 +0530 | [diff] [blame] | 57 | expect(results.softwareProductValidationResult.testResultToDisplay[vspIdAndVer]).toBeTruthy(); |
Vodafone | 804ec68 | 2019-03-18 15:46:53 +0530 | [diff] [blame] | 58 | }); |
| 59 | |
atulpurohit | 8b34684 | 2019-11-05 14:31:56 +0530 | [diff] [blame] | 60 | it('mapStateToProps success data test', () => { |
Vodafone | 804ec68 | 2019-03-18 15:46:53 +0530 | [diff] [blame] | 61 | const vspTestResults = VSPTestResultsSuccessFactory.build(); |
Vodafone | 1875093 | 2019-04-05 15:49:06 +0530 | [diff] [blame] | 62 | const vspTestsMap = VSPTestsMapFactory.build(); |
atulpurohit | 8b34684 | 2019-11-05 14:31:56 +0530 | [diff] [blame] | 63 | const vspChecksList = VSPChecksFactory.build(); |
Vodafone | 804ec68 | 2019-03-18 15:46:53 +0530 | [diff] [blame] | 64 | var obj = { |
| 65 | softwareProduct: { |
| 66 | softwareProductValidation: { |
atulpurohit | 8b34684 | 2019-11-05 14:31:56 +0530 | [diff] [blame] | 67 | }, |
| 68 | softwareProductValidationResult: { |
Vodafone | 1875093 | 2019-04-05 15:49:06 +0530 | [diff] [blame] | 69 | vspTestResults: vspTestResults.vspTestResults, |
atulpurohit | 8b34684 | 2019-11-05 14:31:56 +0530 | [diff] [blame] | 70 | vspChecks: vspChecksList, |
| 71 | refreshValidationResults: [] |
Vodafone | 804ec68 | 2019-03-18 15:46:53 +0530 | [diff] [blame] | 72 | } |
| 73 | } |
| 74 | }; |
| 75 | var results = mapStateToProps(obj); |
atulpurohit | 8b34684 | 2019-11-05 14:31:56 +0530 | [diff] [blame] | 76 | expect(results.softwareProductValidationResult.vspTestResults).toBeTruthy(); |
Vodafone | 804ec68 | 2019-03-18 15:46:53 +0530 | [diff] [blame] | 77 | }); |
| 78 | |
| 79 | it('SoftwareProductValidationResultsView test fail render test', () => { |
| 80 | const vspTestResults = VSPTestResultsFailureFactory.build(); |
Vodafone | 1875093 | 2019-04-05 15:49:06 +0530 | [diff] [blame] | 81 | const vspTestsMap = VSPTestsMapFactory.build(); |
atulpurohit | 8b34684 | 2019-11-05 14:31:56 +0530 | [diff] [blame] | 82 | const testResultKeys = VSPTestResultKeysFactory.build(); |
| 83 | const vspChecksList = VSPChecksFactory.build(); |
Vodafone | 804ec68 | 2019-03-18 15:46:53 +0530 | [diff] [blame] | 84 | |
| 85 | const version = { |
| 86 | name: 1 |
| 87 | }; |
| 88 | const softwareProductId = '1234'; |
atulpurohit | 8b34684 | 2019-11-05 14:31:56 +0530 | [diff] [blame] | 89 | var testResultToDisplay = {}; |
| 90 | var vspIdAndVer = softwareProductId+version.name; |
| 91 | testResultToDisplay[vspIdAndVer] = vspTestResults.vspTestResults; |
| 92 | var testResultKeyByVspId = {}; |
| 93 | testResultKeyByVspId[vspIdAndVer] = testResultKeys.testResultKeys; |
| 94 | var obj = { |
| 95 | softwareProductId: softwareProductId, |
| 96 | version: version, |
| 97 | softwareProductValidation:{ |
| 98 | testResultKeys: testResultKeys.testResultKeys |
| 99 | }, |
| 100 | softwareProductValidationResult: { |
| 101 | testResultToDisplay: testResultToDisplay, |
| 102 | vspChecks: vspChecksList, |
| 103 | refreshValidationResults: [], |
| 104 | testResultKeys: testResultKeyByVspId |
| 105 | } |
| 106 | }; |
| 107 | |
Vodafone | 804ec68 | 2019-03-18 15:46:53 +0530 | [diff] [blame] | 108 | let vspValidationResultsView = TestUtils.renderIntoDocument( |
| 109 | <SoftwareProductValidationResultsView {...obj} /> |
| 110 | ); |
| 111 | expect(vspValidationResultsView).toBeTruthy(); |
| 112 | }); |
| 113 | |
| 114 | it('SoftwareProductValidationResultsView test success render test', () => { |
| 115 | const vspTestResults = VSPTestResultsSuccessFactory.build(); |
atulpurohit | 8b34684 | 2019-11-05 14:31:56 +0530 | [diff] [blame] | 116 | const testResultKeys = VSPTestResultKeysFactory.build(); |
Vodafone | 1875093 | 2019-04-05 15:49:06 +0530 | [diff] [blame] | 117 | const vspTestsMap = VSPTestsMapFactory.build(); |
atulpurohit | 8b34684 | 2019-11-05 14:31:56 +0530 | [diff] [blame] | 118 | const vspChecksList = VSPChecksFactory.build(); |
Vodafone | 804ec68 | 2019-03-18 15:46:53 +0530 | [diff] [blame] | 119 | let version = { |
| 120 | name: 1 |
| 121 | }; |
atulpurohit | 8b34684 | 2019-11-05 14:31:56 +0530 | [diff] [blame] | 122 | |
Vodafone | 804ec68 | 2019-03-18 15:46:53 +0530 | [diff] [blame] | 123 | const softwareProductId = '1234'; |
atulpurohit | 8b34684 | 2019-11-05 14:31:56 +0530 | [diff] [blame] | 124 | var testResultToDisplay = {}; |
| 125 | var vspIdAndVer = softwareProductId+version.name; |
| 126 | testResultToDisplay[vspIdAndVer] = vspTestResults.vspTestResults; |
| 127 | var testResultKeyByVspId = {}; |
| 128 | testResultKeyByVspId[vspIdAndVer] = testResultKeys.testResultKeys; |
| 129 | |
Vodafone | 804ec68 | 2019-03-18 15:46:53 +0530 | [diff] [blame] | 130 | var obj = { |
| 131 | softwareProductId: softwareProductId, |
| 132 | version: version, |
atulpurohit | 8b34684 | 2019-11-05 14:31:56 +0530 | [diff] [blame] | 133 | softwareProductValidation:{ |
| 134 | testResultKeys: testResultKeys.testResultKeys |
| 135 | }, |
| 136 | softwareProductValidationResult: { |
| 137 | testResultToDisplay: testResultToDisplay, |
| 138 | vspChecks: vspChecksList |
Vodafone | 804ec68 | 2019-03-18 15:46:53 +0530 | [diff] [blame] | 139 | } |
| 140 | }; |
| 141 | let vspValidationResultsView = TestUtils.renderIntoDocument( |
| 142 | <SoftwareProductValidationResultsView {...obj} /> |
| 143 | ); |
| 144 | expect(vspValidationResultsView).toBeTruthy(); |
| 145 | }); |
| 146 | }); |