AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 1 | /*! |
| 2 | * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. |
| 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 |
| 13 | * or implied. See the License for the specific language governing |
| 14 | * permissions and limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | import {mapStateToProps} from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverview.js'; |
| 18 | import {overviewEditorHeaders, selectedButton} from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js'; |
| 19 | |
| 20 | import {LicenseModelOverviewFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; |
| 21 | import { EntitlementPoolStoreFactory as EntitlementPool, EntitlementPoolDataListFactory } from 'test-utils/factories/licenseModel/EntitlementPoolFactories.js'; |
| 22 | import { FeatureGroupStoreFactory as FeatureGroup, FeatureGroupDataListFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js'; |
| 23 | import {LicenseAgreementStoreFactory as LicenseAgreement, LicenseAgreementDataListFactory} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js'; |
| 24 | import { LicenseKeyGroupStoreFactory as LicenseKeyGroup, LicenseKeyGroupDataListFactory} from 'test-utils/factories/licenseModel/LicenseKeyGroupFactories.js'; |
| 25 | |
| 26 | describe('License Model Overview: ', function () { |
| 27 | |
| 28 | it('should mapper exist', () => { |
| 29 | expect(mapStateToProps).toBeTruthy(); |
| 30 | }); |
| 31 | |
ilanap | c6a41de | 2017-11-07 11:54:10 +0200 | [diff] [blame] | 32 | const VLM1 = LicenseModelOverviewFactory.build({ |
| 33 | featureGroup: { |
| 34 | featureGroupsList: [], |
| 35 | }, |
| 36 | entitlementPool: { |
| 37 | entitlementPoolsList: [] |
| 38 | }, |
| 39 | licenseKeyGroup: { |
| 40 | licenseKeyGroupsList: [] |
| 41 | } |
| 42 | }); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 43 | |
| 44 | it('should mapper return vlm overview basic data', () => { |
| 45 | const state = { |
| 46 | licenseModel: VLM1 |
| 47 | }; |
| 48 | |
| 49 | var props = mapStateToProps(state); |
| 50 | expect(props.isReadOnlyMode).toEqual(true); |
| 51 | expect(props.isDisplayModal).toEqual(false); |
| 52 | expect(props.modalHeader).toEqual(undefined); |
| 53 | expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id); |
| 54 | expect(props.licensingDataList).toEqual([]); |
ilanap | c6a41de | 2017-11-07 11:54:10 +0200 | [diff] [blame] | 55 | expect(props.orphanDataList).toEqual([]); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 56 | expect(props.selectedTab).toEqual(selectedButton.VLM_LIST_VIEW); |
| 57 | }); |
| 58 | |
| 59 | it('should mapper return overview data for show LA modal', () => { |
| 60 | const VLM1 = LicenseModelOverviewFactory.build({ |
| 61 | licenseAgreement: { |
| 62 | licenseAgreementEditor: { |
| 63 | data: LicenseAgreement.build() |
| 64 | } |
ilanap | c6a41de | 2017-11-07 11:54:10 +0200 | [diff] [blame] | 65 | }, |
| 66 | featureGroup: { |
| 67 | featureGroupsList: [], |
| 68 | }, |
| 69 | entitlementPool: { |
| 70 | entitlementPoolsList: [] |
| 71 | }, |
| 72 | licenseKeyGroup: { |
| 73 | licenseKeyGroupsList: [] |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 74 | } |
| 75 | }); |
| 76 | |
| 77 | var state = { |
| 78 | licenseModel: VLM1 |
| 79 | }; |
| 80 | |
| 81 | var props = mapStateToProps(state); |
| 82 | expect(props.isReadOnlyMode).toEqual(true); |
| 83 | expect(props.isDisplayModal).toEqual(true); |
| 84 | expect(props.modalHeader).toEqual(overviewEditorHeaders.LICENSE_AGREEMENT); |
| 85 | expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id); |
| 86 | expect(props.licensingDataList).toEqual([]); |
| 87 | expect(props.selectedTab).toEqual(selectedButton.VLM_LIST_VIEW); |
| 88 | }); |
| 89 | |
| 90 | it('should mapper return overview data for show FG modal', () => { |
| 91 | |
| 92 | const VLM1 = LicenseModelOverviewFactory.build({ |
| 93 | featureGroup: { |
| 94 | featureGroupsList: [], |
| 95 | featureGroupEditor: { |
| 96 | data: FeatureGroup.build() |
| 97 | } |
| 98 | }, |
| 99 | entitlementPool: { |
| 100 | entitlementPoolsList: [] |
| 101 | }, |
| 102 | licenseKeyGroup: { |
| 103 | licenseKeyGroupsList: [] |
| 104 | }, |
| 105 | licenseModelOverview: { |
| 106 | selectedTab: selectedButton.NOT_IN_USE |
| 107 | } |
| 108 | }); |
| 109 | |
| 110 | var state = { |
| 111 | licenseModel: VLM1 |
| 112 | }; |
| 113 | |
| 114 | var props = mapStateToProps(state); |
| 115 | expect(props.isReadOnlyMode).toEqual(true); |
| 116 | expect(props.isDisplayModal).toEqual(true); |
| 117 | expect(props.modalHeader).toEqual(overviewEditorHeaders.FEATURE_GROUP); |
| 118 | expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id); |
| 119 | expect(props.licensingDataList).toEqual([]); |
| 120 | expect(props.selectedTab).toEqual(selectedButton.NOT_IN_USE); |
| 121 | }); |
| 122 | |
| 123 | it('should mapper return overview data for show EP modal', () => { |
ilanap | c6a41de | 2017-11-07 11:54:10 +0200 | [diff] [blame] | 124 | const VLM1 = LicenseModelOverviewFactory.build( { |
| 125 | featureGroup: { |
| 126 | featureGroupsList: [], |
| 127 | }, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 128 | entitlementPool: { |
ilanap | c6a41de | 2017-11-07 11:54:10 +0200 | [diff] [blame] | 129 | entitlementPoolsList: [], |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 130 | entitlementPoolEditor: { |
| 131 | data: EntitlementPool.build() |
| 132 | } |
ilanap | c6a41de | 2017-11-07 11:54:10 +0200 | [diff] [blame] | 133 | }, |
| 134 | licenseKeyGroup: { |
| 135 | licenseKeyGroupsList: [] |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 136 | } |
| 137 | }); |
| 138 | |
| 139 | var state = { |
| 140 | licenseModel: VLM1 |
| 141 | }; |
| 142 | |
| 143 | var props = mapStateToProps(state); |
| 144 | expect(props.isReadOnlyMode).toEqual(true); |
| 145 | expect(props.isDisplayModal).toEqual(true); |
| 146 | expect(props.modalHeader).toEqual(overviewEditorHeaders.ENTITLEMENT_POOL); |
| 147 | expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id); |
| 148 | expect(props.licensingDataList).toEqual([]); |
| 149 | expect(props.selectedTab).toEqual(selectedButton.VLM_LIST_VIEW); |
| 150 | }); |
| 151 | |
| 152 | it('should mapper return overview data for show LKG modal', () => { |
| 153 | const VLM1 = LicenseModelOverviewFactory.build({ |
| 154 | licenseKeyGroup: { |
| 155 | licenseKeyGroupsList: [], |
| 156 | licenseKeyGroupsEditor: { |
| 157 | data: LicenseKeyGroup.build() |
| 158 | } |
| 159 | }, |
| 160 | entitlementPool: { |
| 161 | entitlementPoolsList: [] |
| 162 | }, |
| 163 | featureGroup: { |
| 164 | featureGroupsList: [] |
| 165 | }, |
| 166 | licenseModelOverview: { |
| 167 | selectedTab: selectedButton.NOT_IN_USE |
| 168 | } |
| 169 | }); |
| 170 | |
| 171 | var state = { |
| 172 | licenseModel: VLM1 |
| 173 | }; |
| 174 | |
| 175 | var props = mapStateToProps(state); |
| 176 | expect(props.isReadOnlyMode).toEqual(true); |
| 177 | expect(props.isDisplayModal).toEqual(true); |
| 178 | expect(props.modalHeader).toEqual(overviewEditorHeaders.LICENSE_KEY_GROUP); |
| 179 | expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id); |
| 180 | expect(props.licensingDataList).toEqual([]); |
| 181 | expect(props.selectedTab).toEqual(selectedButton.NOT_IN_USE); |
| 182 | }); |
| 183 | |
| 184 | it('should mapper return overview data for Full-hierarchy list view', () => { |
| 185 | let EP1 = EntitlementPool.build(); |
| 186 | let LKG1 = LicenseKeyGroup.build(); |
| 187 | let FG1 = FeatureGroup.build({ |
| 188 | entitlementPoolsIds: [EP1.id], |
| 189 | licenseKeyGroupsIds: [LKG1.id] |
| 190 | }); |
| 191 | EP1.referencingFeatureGroups = [FG1.id]; |
| 192 | LKG1.referencingFeatureGroups = [FG1.id]; |
| 193 | let LA1 = LicenseAgreement.build({ |
| 194 | featureGroupsIds: [FG1.id] |
| 195 | }); |
| 196 | FG1.referencingLicenseAgreements = LA1.id; |
| 197 | let LA2 = LicenseAgreement.build(); |
| 198 | |
| 199 | const VLM1 = LicenseModelOverviewFactory.build({ |
| 200 | licenseAgreement: { |
| 201 | licenseAgreementList: [LA1, LA2] |
| 202 | }, |
| 203 | featureGroup: { |
| 204 | featureGroupsList: [FG1] |
| 205 | }, |
| 206 | entitlementPool: { |
| 207 | entitlementPoolsList: [EP1] |
| 208 | }, |
| 209 | licenseKeyGroup: { |
| 210 | licenseKeyGroupsList: [LKG1] |
| 211 | }, |
| 212 | }); |
| 213 | |
| 214 | const state = { |
| 215 | licenseModel: VLM1 |
| 216 | }; |
| 217 | |
| 218 | const expectedLicensingDataList = [ |
| 219 | LicenseAgreementDataListFactory.build({ |
| 220 | ...LA1, |
| 221 | children: [ |
| 222 | FeatureGroupDataListFactory.build({ |
| 223 | ...FG1, |
| 224 | children: [ |
| 225 | EntitlementPoolDataListFactory.build(EP1), |
| 226 | LicenseKeyGroupDataListFactory.build(LKG1) |
| 227 | ] |
| 228 | }) |
| 229 | ] |
| 230 | }), |
| 231 | LicenseAgreementDataListFactory.build(LA2) |
| 232 | ]; |
| 233 | |
| 234 | var props = mapStateToProps(state); |
| 235 | |
| 236 | expect(props.isReadOnlyMode).toEqual(true); |
| 237 | expect(props.isDisplayModal).toEqual(false); |
| 238 | expect(props.modalHeader).toEqual(undefined); |
| 239 | expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id); |
| 240 | expect(props.licensingDataList).toEqual(expectedLicensingDataList); |
| 241 | expect(props.selectedTab).toEqual(selectedButton.VLM_LIST_VIEW); |
| 242 | }); |
| 243 | |
| 244 | it('should mapper return overview data for list view with 2 levels', () => { |
| 245 | let EP1 = EntitlementPool.build(); |
| 246 | let LKG1 = LicenseKeyGroup.build(); |
| 247 | let FG1 = FeatureGroup.build(); |
| 248 | let LA1 = LicenseAgreement.build({ |
| 249 | featureGroupsIds: [FG1.id] |
| 250 | }); |
| 251 | let LA2 = LicenseAgreement.build(); |
| 252 | FG1.referencingLicenseAgreements = [LA1.id]; |
| 253 | |
| 254 | const VLM1 = LicenseModelOverviewFactory.build({ |
| 255 | licenseAgreement: { |
| 256 | licenseAgreementList: [LA1, LA2] |
| 257 | }, |
| 258 | featureGroup: { |
| 259 | featureGroupsList: [FG1] |
| 260 | }, |
| 261 | entitlementPool: { |
| 262 | entitlementPoolsList: [EP1] |
| 263 | }, |
| 264 | licenseKeyGroup: { |
| 265 | licenseKeyGroupsList: [LKG1] |
| 266 | }, |
| 267 | }); |
| 268 | |
| 269 | const state = { |
| 270 | licenseModel: VLM1 |
| 271 | }; |
| 272 | |
| 273 | const expectedLicensingDataList = [ |
| 274 | LicenseAgreementDataListFactory.build({ |
| 275 | ...LA1, |
| 276 | children: [ |
| 277 | FeatureGroupDataListFactory.build(FG1) |
| 278 | ] |
| 279 | }), |
| 280 | LicenseAgreementDataListFactory.build(LA2) |
| 281 | ]; |
| 282 | |
| 283 | var props = mapStateToProps(state); |
| 284 | |
| 285 | expect(props.isReadOnlyMode).toEqual(true); |
| 286 | expect(props.isDisplayModal).toEqual(false); |
| 287 | expect(props.modalHeader).toEqual(undefined); |
| 288 | expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id); |
| 289 | expect(props.licensingDataList).toEqual(expectedLicensingDataList); |
| 290 | expect(props.selectedTab).toEqual(selectedButton.VLM_LIST_VIEW); |
| 291 | }); |
| 292 | |
| 293 | it('should mapper return overview data for Full NOT-IN-USE list view', () => { |
| 294 | let EP1 = EntitlementPool.build(); |
| 295 | let LKG1 = LicenseKeyGroup.build(); |
| 296 | let FG1 = FeatureGroup.build(); |
| 297 | |
| 298 | const VLM1 = LicenseModelOverviewFactory.build({ |
| 299 | licenseAgreement: { licenseAgreementList: [] }, |
| 300 | featureGroup: { |
| 301 | featureGroupsList: [FG1] |
| 302 | }, |
| 303 | entitlementPool: { |
| 304 | entitlementPoolsList: [EP1] |
| 305 | }, |
| 306 | licenseKeyGroup: { |
| 307 | licenseKeyGroupsList: [LKG1] |
| 308 | }, |
| 309 | licenseModelOverview: { |
| 310 | selectedTab: selectedButton.NOT_IN_USE |
| 311 | } |
| 312 | }); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 313 | const state = { |
| 314 | licenseModel: VLM1 |
| 315 | }; |
| 316 | |
| 317 | const expectedLicensingDataList = [ |
| 318 | FeatureGroupDataListFactory.build(FG1), |
| 319 | EntitlementPoolDataListFactory.build(EP1), |
| 320 | LicenseKeyGroupDataListFactory.build(LKG1) |
| 321 | ]; |
| 322 | |
| 323 | var props = mapStateToProps(state); |
| 324 | |
| 325 | expect(props.isReadOnlyMode).toEqual(true); |
| 326 | expect(props.isDisplayModal).toEqual(false); |
| 327 | expect(props.modalHeader).toEqual(undefined); |
| 328 | expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id); |
ilanap | c6a41de | 2017-11-07 11:54:10 +0200 | [diff] [blame] | 329 | expect(props.licensingDataList).toEqual([]); |
| 330 | expect(props.orphanDataList).toEqual(expectedLicensingDataList); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 331 | expect(props.selectedTab).toEqual(selectedButton.NOT_IN_USE); |
| 332 | }); |
| 333 | |
| 334 | it('should mapper return overview data for NOT-IN-USE list view (FG with children)', () => { |
| 335 | let EP1 = EntitlementPool.build(); |
| 336 | let LKG1 = LicenseKeyGroup.build(); |
| 337 | let FG1 = FeatureGroup.build({ |
| 338 | entitlementPoolsIds: [EP1.id], |
| 339 | licenseKeyGroupsIds: [LKG1.id] |
| 340 | }); |
| 341 | EP1.referencingFeatureGroups = [FG1.id]; |
| 342 | LKG1.referencingFeatureGroups = [FG1.id]; |
| 343 | |
| 344 | const VLM1 = LicenseModelOverviewFactory.build({ |
| 345 | licenseAgreement: { licenseAgreementList: [] }, |
| 346 | featureGroup: { |
| 347 | featureGroupsList: [FG1] |
| 348 | }, |
| 349 | entitlementPool: { |
| 350 | entitlementPoolsList: [EP1] |
| 351 | }, |
| 352 | licenseKeyGroup: { |
| 353 | licenseKeyGroupsList: [LKG1] |
| 354 | }, |
| 355 | licenseModelOverview: { |
| 356 | selectedTab: selectedButton.NOT_IN_USE |
| 357 | } |
| 358 | }); |
| 359 | |
| 360 | const state = { |
| 361 | licenseModel: VLM1 |
| 362 | }; |
| 363 | |
| 364 | const expectedLicensingDataList = [ |
| 365 | FeatureGroupDataListFactory.build({ |
| 366 | ...FG1, |
| 367 | children: [ |
| 368 | EntitlementPoolDataListFactory.build(EP1), |
| 369 | LicenseKeyGroupDataListFactory.build(LKG1)] |
| 370 | }) |
| 371 | ]; |
| 372 | |
| 373 | var props = mapStateToProps(state); |
| 374 | |
| 375 | expect(props.isReadOnlyMode).toEqual(true); |
| 376 | expect(props.isDisplayModal).toEqual(false); |
| 377 | expect(props.modalHeader).toEqual(undefined); |
| 378 | expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id); |
ilanap | c6a41de | 2017-11-07 11:54:10 +0200 | [diff] [blame] | 379 | expect(props.licensingDataList).toEqual([]); |
| 380 | expect(props.orphanDataList).toEqual(expectedLicensingDataList); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 381 | expect(props.selectedTab).toEqual(selectedButton.NOT_IN_USE); |
| 382 | }); |
ilanap | c6a41de | 2017-11-07 11:54:10 +0200 | [diff] [blame] | 383 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 384 | }); |