AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 1 | /*! |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 2 | * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 3 | * |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 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 |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
| 13 | * or implied. See the License for the specific language governing |
| 14 | * permissions and limitations under the License. |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 15 | */ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 16 | import React from 'react'; |
| 17 | import TestUtils from 'react-addons-test-utils'; |
| 18 | import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/details/SoftwareProductDetails.js'; |
| 19 | import SoftwareProductDetailsView from 'sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 20 | import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; |
| 21 | import {CategoryWithSubFactory} from 'test-utils/factories/softwareProduct/VSPCategoriesFactory.js'; |
| 22 | import {LicenseAgreementStoreFactory} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js'; |
| 23 | import {FeatureGroupStoreFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js'; |
| 24 | import {SchemaGenericFieldInfoFactory} from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js'; |
| 25 | import {default as VspQdataFactory, VspDataMapFactory} from 'test-utils/factories/softwareProduct/VspQdataFactory.js'; |
| 26 | import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 27 | |
| 28 | describe('Software Product Details: ', function () { |
| 29 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 30 | let currentSoftwareProduct = {}, currentSoftwareProductWithLicensingData = {}, softwareProductCategories = [], |
| 31 | finalizedLicenseModelList, licenseAgreementList, featureGroupsList, qdata = {}, dataMap = {}, genericFieldInfo = {}, qGenericFieldInfo = {}; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 32 | let dummyFunc = () => {}; |
| 33 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 34 | beforeAll(function() { |
| 35 | finalizedLicenseModelList = FinalizedLicenseModelFactory.buildList(2); |
| 36 | currentSoftwareProduct = VSPEditorFactory.build({ |
| 37 | id: 'RTRTG454545', |
| 38 | vendorId: finalizedLicenseModelList[0].id, |
| 39 | vendorName: finalizedLicenseModelList[0].vendorName |
| 40 | }); |
| 41 | softwareProductCategories = CategoryWithSubFactory.buildList(2, {}, {quantity: 1}); |
| 42 | licenseAgreementList = LicenseAgreementStoreFactory.buildList(2); |
| 43 | featureGroupsList = FeatureGroupStoreFactory.buildList(2, {referencingLicenseAgreements: [licenseAgreementList[0].id]}); |
| 44 | qdata = VspQdataFactory.build(); |
| 45 | dataMap = VspDataMapFactory.build(); |
| 46 | currentSoftwareProductWithLicensingData = { |
| 47 | ...currentSoftwareProduct, |
| 48 | licensingData: { |
| 49 | licenseAgreement: licenseAgreementList[0].id, |
| 50 | featureGroups: [featureGroupsList[0].id] |
| 51 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 52 | }; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 53 | genericFieldInfo = { |
| 54 | 'name': { |
| 55 | isValid: true, |
| 56 | errorText: '', |
| 57 | validations: [{type: 'validateName', data: true}, {type: 'maxLength', data: 120}, { |
| 58 | type: 'required', |
| 59 | data: true |
| 60 | }] |
| 61 | }, |
| 62 | 'description': { |
| 63 | isValid: true, |
| 64 | errorText: '', |
| 65 | validations: [{type: 'required', data: true}] |
| 66 | } |
| 67 | }; |
| 68 | qGenericFieldInfo = SchemaGenericFieldInfoFactory.build(); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 69 | }); |
| 70 | |
| 71 | it('should mapper exist', () => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 72 | expect(mapStateToProps).toBeTruthy(); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 73 | }); |
| 74 | |
| 75 | it('should mapper return vsp basic data', () => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 76 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 77 | var obj = { |
| 78 | softwareProduct: { |
| 79 | softwareProductEditor: { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 80 | data: currentSoftwareProduct, |
| 81 | genericFieldInfo |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 82 | }, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 83 | softwareProductCategories, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 84 | softwareProductQuestionnaire: { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 85 | qdata, |
| 86 | genericFieldInfo: qGenericFieldInfo, |
| 87 | dataMap |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 88 | } |
| 89 | }, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 90 | finalizedLicenseModelList, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 91 | licenseModel: { |
| 92 | licenseAgreement: { |
| 93 | licenseAgreementList: [] |
| 94 | }, |
| 95 | featureGroup: { |
| 96 | featureGroupsList: [] |
| 97 | } |
| 98 | } |
| 99 | }; |
| 100 | |
| 101 | var result = mapStateToProps(obj); |
| 102 | expect(result.currentSoftwareProduct).toEqual(currentSoftwareProduct); |
| 103 | expect(result.finalizedLicenseModelList).toEqual(finalizedLicenseModelList); |
| 104 | expect(result.finalizedLicenseModelList.length).toBeGreaterThan(0); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 105 | expect(finalizedLicenseModelList[0]).toMatchObject({ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 106 | id: result.currentSoftwareProduct.vendorId, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 107 | vendorName: result.currentSoftwareProduct.vendorName |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 108 | }); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 109 | expect(result.softwareProductCategories).toEqual(softwareProductCategories); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 110 | expect(result.licenseAgreementList).toEqual([]); |
| 111 | expect(result.featureGroupsList).toEqual([]); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 112 | expect(result.qdata).toEqual(qdata); |
| 113 | expect(result.dataMap).toEqual(dataMap); |
| 114 | expect(result.isFormValid).toEqual(true); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 115 | expect(result.isReadOnlyMode).toEqual(true); |
| 116 | }); |
| 117 | |
| 118 | it('should mapper return vsp data with selected licenseAgreement and featureGroup', () => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 119 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 120 | var obj = { |
| 121 | softwareProduct: { |
| 122 | softwareProductEditor: { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 123 | data: currentSoftwareProductWithLicensingData, |
| 124 | genericFieldInfo |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 125 | }, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 126 | softwareProductCategories, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 127 | softwareProductQuestionnaire: { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 128 | qdata, |
| 129 | genericFieldInfo: qGenericFieldInfo, |
| 130 | dataMap |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 131 | } |
| 132 | }, |
| 133 | finalizedLicenseModelList: finalizedLicenseModelList, |
| 134 | licenseModel: { |
| 135 | licenseAgreement: { |
| 136 | licenseAgreementList: licenseAgreementList |
| 137 | }, |
| 138 | featureGroup: { |
| 139 | featureGroupsList: featureGroupsList |
| 140 | } |
| 141 | } |
| 142 | }; |
| 143 | |
| 144 | var result = mapStateToProps(obj); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 145 | expect(result.currentSoftwareProduct).toEqual(currentSoftwareProductWithLicensingData); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 146 | expect(result.finalizedLicenseModelList).toEqual(finalizedLicenseModelList); |
| 147 | expect(result.finalizedLicenseModelList.length).toBeGreaterThan(0); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 148 | expect(result.finalizedLicenseModelList[0]).toMatchObject({ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 149 | id: result.currentSoftwareProduct.vendorId, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 150 | vendorName: result.currentSoftwareProduct.vendorName |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 151 | }); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 152 | expect(result.softwareProductCategories).toEqual(softwareProductCategories); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 153 | expect(result.licenseAgreementList).toEqual(licenseAgreementList); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 154 | expect(result.licenseAgreementList[0]).toMatchObject({...licenseAgreementList[0], id: result.currentSoftwareProduct.licensingData.licenseAgreement}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 155 | result.currentSoftwareProduct.licensingData.featureGroups.forEach(fg => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 156 | expect(featureGroupsList[0]).toMatchObject({...featureGroupsList[0], id: fg}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 157 | }); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 158 | expect(result.qdata).toEqual(qdata); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 159 | expect(result.isReadOnlyMode).toEqual(true); |
| 160 | }); |
| 161 | |
| 162 | it('VSP Details view test', () => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 163 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 164 | let params = { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 165 | currentSoftwareProduct, |
| 166 | softwareProductCategories, |
| 167 | qdata, |
| 168 | dataMap, |
| 169 | isFormValid: true, |
| 170 | finalizedLicenseModelList, |
| 171 | licenseAgreementList, |
| 172 | featureGroupsList, |
| 173 | genericFieldInfo, |
| 174 | qGenericFieldInfo, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 175 | }; |
| 176 | var renderer = TestUtils.createRenderer(); |
| 177 | renderer.render( |
| 178 | <SoftwareProductDetailsView |
| 179 | {...params} |
| 180 | onSubmit = {dummyFunc} |
| 181 | onDataChanged = {dummyFunc} |
| 182 | onValidityChanged = {dummyFunc} |
| 183 | onQDataChanged = {dummyFunc} |
| 184 | onVendorParamChanged = {dummyFunc}/> |
| 185 | ); |
| 186 | let renderedOutput = renderer.getRenderOutput(); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 187 | expect(renderedOutput).toBeTruthy(); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 188 | }); |
| 189 | |
| 190 | it('in view: should change vendorId and update vsp licensing-version', done => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 191 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 192 | let params = { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 193 | currentSoftwareProduct: currentSoftwareProductWithLicensingData, |
| 194 | softwareProductCategories, |
| 195 | qdata, |
| 196 | dataMap, |
| 197 | isFormValid: true, |
| 198 | genericFieldInfo, |
| 199 | qGenericFieldInfo, |
| 200 | finalizedLicenseModelList, |
| 201 | licenseAgreementList, |
| 202 | featureGroupsList |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 203 | }; |
| 204 | const onVendorChangedListener = (deltaData) => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 205 | expect(deltaData.vendorId).toEqual(finalizedLicenseModelList[1].id); |
| 206 | expect(deltaData.vendorName).toEqual(finalizedLicenseModelList[1].vendorName); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 207 | expect(deltaData.licensingVersion).toEqual(''); |
| 208 | expect(deltaData.licensingData).toEqual({}); |
| 209 | done(); |
| 210 | }; |
| 211 | |
| 212 | var vspDetailsView = TestUtils.renderIntoDocument(<SoftwareProductDetailsView |
| 213 | currentSoftwareProduct = {params.currentSoftwareProduct} |
| 214 | softwareProductCategories = {params.softwareProductCategories} |
| 215 | qdata = {params.qdata} |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 216 | qGenericFieldInfo = {params.qGenericFieldInfo} |
| 217 | genericFieldInfo = {params.genericFieldInfo} |
| 218 | isFormValid={params.isFormValid} |
| 219 | dataMap={params.dataMap} |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 220 | finalizedLicenseModelList = {params.finalizedLicenseModelList} |
| 221 | licenseAgreementList = {params.licenseAgreementList} |
| 222 | featureGroupsList = {params.featureGroupsList} |
| 223 | onSubmit = {dummyFunc} |
| 224 | onDataChanged = {dummyFunc} |
| 225 | onValidityChanged = {dummyFunc} |
| 226 | onQDataChanged = {dummyFunc} |
| 227 | onVendorParamChanged = {(deltaData) => onVendorChangedListener(deltaData)}/>); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 228 | expect(vspDetailsView).toBeTruthy(); |
| 229 | vspDetailsView.onVendorParamChanged({vendorId: finalizedLicenseModelList[1].id}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 230 | }); |
| 231 | |
| 232 | it('in view: should change licensing-version and update licensing data', done => { |
| 233 | let params = { |
| 234 | currentSoftwareProduct: currentSoftwareProduct, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 235 | softwareProductCategories, |
| 236 | qdata, |
| 237 | dataMap, |
| 238 | isFormValid: true, |
| 239 | genericFieldInfo, |
| 240 | qGenericFieldInfo, |
| 241 | finalizedLicenseModelList, |
| 242 | licenseAgreementList, |
| 243 | featureGroupsList |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 244 | }; |
| 245 | const onVendorChangedListener = (deltaData) => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 246 | expect(deltaData.vendorId).toEqual(finalizedLicenseModelList[1].id); |
| 247 | expect(deltaData.vendorName).toEqual(finalizedLicenseModelList[1].vendorName); |
| 248 | expect(deltaData.licensingVersion).toEqual(finalizedLicenseModelList[1].viewableVersion[0]); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 249 | expect(deltaData.licensingData).toEqual({}); |
| 250 | done(); |
| 251 | }; |
| 252 | |
| 253 | let vspDetailsView = TestUtils.renderIntoDocument(<SoftwareProductDetailsView |
| 254 | {...params} |
| 255 | onSubmit = {dummyFunc} |
| 256 | onDataChanged = {dummyFunc} |
| 257 | onValidityChanged = {dummyFunc} |
| 258 | onQDataChanged = {dummyFunc} |
| 259 | onVendorParamChanged = {(deltaData) => onVendorChangedListener(deltaData)}/>); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 260 | expect(vspDetailsView).toBeTruthy(); |
| 261 | vspDetailsView.onVendorParamChanged({vendorId: finalizedLicenseModelList[1].id, licensingVersion: finalizedLicenseModelList[1].viewableVersion[0]}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 262 | }); |
| 263 | |
| 264 | it('in view: should change subcategory', done => { |
| 265 | let params = { |
| 266 | currentSoftwareProduct: currentSoftwareProduct, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 267 | softwareProductCategories, |
| 268 | qdata, |
| 269 | dataMap, |
| 270 | isFormValid: true, |
| 271 | genericFieldInfo, |
| 272 | qGenericFieldInfo, |
| 273 | finalizedLicenseModelList, |
| 274 | licenseAgreementList, |
| 275 | featureGroupsList |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 276 | }; |
| 277 | const onDataChangedListener = ({category, subCategory}) => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 278 | expect(category).toEqual(softwareProductCategories[1].uniqueId); |
| 279 | expect(subCategory).toEqual(softwareProductCategories[1].subcategories[0].uniqueId); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 280 | done(); |
| 281 | }; |
| 282 | |
| 283 | let vspDetailsView = TestUtils.renderIntoDocument(<SoftwareProductDetailsView |
| 284 | {...params} |
| 285 | onSubmit = {dummyFunc} |
| 286 | onDataChanged = {({category, subCategory}) => onDataChangedListener({category, subCategory})} |
| 287 | onValidityChanged = {dummyFunc} |
| 288 | onQDataChanged = {dummyFunc} |
| 289 | onVendorParamChanged = {dummyFunc}/>); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 290 | expect(vspDetailsView).toBeTruthy(); |
| 291 | vspDetailsView.onSelectSubCategory(softwareProductCategories[1].subcategories[0].uniqueId); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 292 | }); |
| 293 | |
| 294 | it('in view: should change feature groups', done => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 295 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 296 | let params = { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 297 | currentSoftwareProduct: currentSoftwareProductWithLicensingData, |
| 298 | softwareProductCategories, |
| 299 | qdata, |
| 300 | dataMap, |
| 301 | isFormValid: true, |
| 302 | genericFieldInfo, |
| 303 | qGenericFieldInfo, |
| 304 | finalizedLicenseModelList, |
| 305 | licenseAgreementList, |
| 306 | featureGroupsList |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 307 | }; |
| 308 | const onDataChangedListener = ({licensingData}) => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 309 | expect(licensingData.licenseAgreement).toEqual(licenseAgreementList[0].id); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 310 | expect(licensingData.featureGroups).toEqual([ |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 311 | {enum: featureGroupsList[0].id, title: featureGroupsList[0].name}, |
| 312 | {enum: featureGroupsList[1].id, title: featureGroupsList[1].name} |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 313 | ]); |
| 314 | done(); |
| 315 | }; |
| 316 | |
| 317 | let vspDetailsView = TestUtils.renderIntoDocument(<SoftwareProductDetailsView |
| 318 | {...params} |
| 319 | onSubmit = {dummyFunc} |
| 320 | onDataChanged = {({licensingData}) => onDataChangedListener({licensingData})} |
| 321 | onValidityChanged = {dummyFunc} |
| 322 | onQDataChanged = {dummyFunc} |
| 323 | onVendorParamChanged = {dummyFunc}/>); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 324 | expect(vspDetailsView).toBeTruthy(); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 325 | vspDetailsView.onFeatureGroupsChanged({featureGroups: [ |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 326 | {enum: featureGroupsList[0].id, title: featureGroupsList[0].name}, |
| 327 | {enum: featureGroupsList[1].id, title: featureGroupsList[1].name} |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 328 | ]}); |
| 329 | }); |
| 330 | |
| 331 | it('in view: should change license agreement', done => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 332 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 333 | let params = { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 334 | currentSoftwareProduct: currentSoftwareProductWithLicensingData, |
| 335 | softwareProductCategories, |
| 336 | qdata, |
| 337 | dataMap, |
| 338 | isFormValid: true, |
| 339 | genericFieldInfo, |
| 340 | qGenericFieldInfo, |
| 341 | finalizedLicenseModelList, |
| 342 | licenseAgreementList, |
| 343 | featureGroupsList |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 344 | }; |
| 345 | const onDataChangedListener = ({licensingData}) => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 346 | expect(licensingData.licenseAgreement).toEqual(licenseAgreementList[1].id); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 347 | expect(licensingData.featureGroups).toEqual([]); |
| 348 | done(); |
| 349 | }; |
| 350 | |
| 351 | let vspDetailsView = TestUtils.renderIntoDocument(<SoftwareProductDetailsView |
| 352 | {...params} |
| 353 | onSubmit = {dummyFunc} |
| 354 | onDataChanged = {({licensingData}) => onDataChangedListener({licensingData})} |
| 355 | onValidityChanged = {dummyFunc} |
| 356 | onQDataChanged = {dummyFunc} |
| 357 | onVendorParamChanged = {dummyFunc}/>); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 358 | expect(vspDetailsView).toBeTruthy(); |
| 359 | vspDetailsView.onLicensingDataChanged({licenseAgreement: licenseAgreementList[1].id, featureGroups: []}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 360 | }); |
| 361 | }); |