svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 1 | /* |
Einav Weiss Keidar | d2f5794 | 2018-02-14 14:00:07 +0200 | [diff] [blame] | 2 | * Copyright © 2016-2018 European Support Limited |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 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 |
Einav Weiss Keidar | d2f5794 | 2018-02-14 14:00:07 +0200 | [diff] [blame] | 7 | * |
svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Einav Weiss Keidar | d2f5794 | 2018-02-14 14:00:07 +0200 | [diff] [blame] | 9 | * |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [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, |
svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 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. |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | import React from 'react'; |
Einav Weiss Keidar | d2f5794 | 2018-02-14 14:00:07 +0200 | [diff] [blame] | 18 | import TestUtils from 'react-dom/test-utils'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 19 | import {defaultStoreFactory} from 'test-utils/factories/onboard/OnboardingCatalogFactories.js'; |
| 20 | import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; |
| 21 | import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; |
| 22 | import {mapStateToProps} from 'sdc-app/onboarding/onboard/Onboard.js'; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 23 | import {catalogItemTypes} from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogConstants.js'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 24 | import OnboardingCatalogView from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogView.jsx'; |
| 25 | import VendorItem from 'sdc-app/onboarding/onboard/onboardingCatalog/VendorItem.jsx'; |
| 26 | import VSPOverlay from 'sdc-app/onboarding/onboard/onboardingCatalog/VSPOverlay.jsx'; |
| 27 | import CatalogItemDetails from 'sdc-app/onboarding/onboard/CatalogItemDetails.jsx'; |
| 28 | import DetailsCatalogView from 'sdc-app/onboarding/onboard/DetailsCatalogView.jsx'; |
| 29 | |
| 30 | describe('OnBoarding Catalog test - View: ', function () { |
| 31 | |
| 32 | |
| 33 | it('mapStateToProps mapper exists', () => { |
| 34 | expect(mapStateToProps).toBeTruthy(); |
| 35 | }); |
| 36 | |
| 37 | it('mapStateToProps data test', () => { |
| 38 | |
| 39 | const licenseModelList = FinalizedLicenseModelFactory.buildList(3); |
| 40 | const softwareProductList = VSPEditorFactory.buildList(4); |
| 41 | const data = defaultStoreFactory.build({licenseModelList, softwareProductList}); |
| 42 | |
| 43 | var results = mapStateToProps(data); |
| 44 | expect(results.softwareProductList).toBeTruthy(); |
| 45 | expect(results.licenseModelList).toBeTruthy(); |
| 46 | expect(results.activeTab).toBeTruthy(); |
| 47 | expect(results.licenseModelList.length).toEqual(3); |
| 48 | }); |
| 49 | |
| 50 | it('licenseModelList creating algorithm test', () => { |
| 51 | |
| 52 | const finalizedLicenseModelList = FinalizedLicenseModelFactory.buildList(3); |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 53 | const licenseModelList = FinalizedLicenseModelFactory.buildList(3); |
| 54 | const finalizedSoftwareProductList = VSPEditorFactory.buildList(4, {vendorId: finalizedLicenseModelList[0].id}); |
| 55 | const softwareProductList = VSPEditorFactory.buildList(4, {vendorId: finalizedLicenseModelList[1].id}); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 56 | const data = defaultStoreFactory.build({licenseModelList, finalizedLicenseModelList, softwareProductList, finalizedSoftwareProductList}); |
| 57 | |
| 58 | var results = mapStateToProps(data); |
| 59 | expect(results.finalizedLicenseModelList[0].softwareProductList.length).toEqual(finalizedSoftwareProductList.length); |
| 60 | }); |
| 61 | |
| 62 | |
| 63 | it('Catalog view test', () => { |
| 64 | |
| 65 | const dummyFunc = () => {}; |
| 66 | const licenseModelList = FinalizedLicenseModelFactory.buildList(3); |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 67 | const softwareProductList = VSPEditorFactory.buildList(4, {vendorId: licenseModelList[0].id}); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 68 | const data = defaultStoreFactory.build({licenseModelList, softwareProductList}); |
| 69 | |
| 70 | const func = { |
| 71 | onAddLicenseModelClick: dummyFunc, |
| 72 | onAddSoftwareProductClick: dummyFunc, |
| 73 | closeVspOverlay: dummyFunc, |
| 74 | onVspOverlayChange: dummyFunc, |
| 75 | onTabClick: dummyFunc, |
| 76 | onSearch: dummyFunc, |
| 77 | onSelectLicenseModel: dummyFunc, |
| 78 | onSelectSoftwareProduct: dummyFunc, |
| 79 | resetOnboardingCatalogStore: '' |
| 80 | }; |
| 81 | |
| 82 | let params = {...func, ...mapStateToProps(data)}; |
| 83 | let CatalogView = TestUtils.renderIntoDocument(<OnboardingCatalogView |
| 84 | {...params}/>); |
| 85 | expect(CatalogView).toBeTruthy(); |
| 86 | }); |
| 87 | |
| 88 | it('VendorItem view test', () => { |
| 89 | let vendor = FinalizedLicenseModelFactory.build(); |
| 90 | const dummyFunc = () => {}; |
| 91 | let params = { |
| 92 | softwareProductList: VSPEditorFactory.buildList(4 ,{vendorId: vendor.id}), |
| 93 | vendor, |
| 94 | onSelectVSP: dummyFunc, |
| 95 | shouldShowOverlay: false, |
| 96 | onVendorSelect: dummyFunc, |
| 97 | onAddVSP: dummyFunc, |
| 98 | onVSPIconClick: dummyFunc, |
| 99 | }; |
| 100 | |
| 101 | let VendorItemView = TestUtils.renderIntoDocument(<VendorItem{...params}/>); |
| 102 | expect(VendorItemView).toBeTruthy(); |
| 103 | }); |
| 104 | |
| 105 | |
| 106 | it('VSPOverlay view test', () => { |
| 107 | |
| 108 | let params = { |
| 109 | VSPList: VSPEditorFactory.buildList(10 ,{vendorId: '1'}), |
| 110 | onSelectVSP: () => {} |
| 111 | }; |
| 112 | |
| 113 | let VSPOverlayView = TestUtils.renderIntoDocument(<div><VSPOverlay {...params}/></div>); |
| 114 | expect(VSPOverlayView).toBeTruthy(); |
| 115 | }); |
| 116 | |
| 117 | it('CatalogItemDetails view test', () => { |
| 118 | |
| 119 | let params = { |
| 120 | catalogItemData: FinalizedLicenseModelFactory.build(), |
| 121 | onSelect: () => {}, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 122 | catalogItemTypeClass: catalogItemTypes.LICENSE_MODEL |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 123 | }; |
| 124 | |
| 125 | let CatalogItemDetailsView = TestUtils.renderIntoDocument(<div><CatalogItemDetails {...params}/></div>); |
| 126 | expect(CatalogItemDetailsView).toBeTruthy(); |
| 127 | }); |
| 128 | |
| 129 | it('DetailsCatalogView view test', () => { |
| 130 | |
| 131 | let params = { |
| 132 | VLMList: FinalizedLicenseModelFactory.buildList(3), |
| 133 | VSPList: VSPEditorFactory.buildList(4), |
| 134 | onSelectVLM: () => {}, |
| 135 | onSelectVSP: () => {}, |
| 136 | onAddVLM: () => {}, |
| 137 | onAddVSP: () => {}, |
| 138 | filter: '' |
| 139 | }; |
| 140 | |
| 141 | let AllCatalog = TestUtils.renderIntoDocument(<DetailsCatalogView {...params}/>); |
| 142 | expect(AllCatalog).toBeTruthy(); |
| 143 | }); |
| 144 | }); |