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 React from 'react'; |
| 18 | import TestUtils from 'react-addons-test-utils'; |
| 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'; |
| 23 | import OnboardingCatalogView from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogView.jsx'; |
| 24 | import VendorItem from 'sdc-app/onboarding/onboard/onboardingCatalog/VendorItem.jsx'; |
| 25 | import VSPOverlay from 'sdc-app/onboarding/onboard/onboardingCatalog/VSPOverlay.jsx'; |
| 26 | import CatalogItemDetails from 'sdc-app/onboarding/onboard/CatalogItemDetails.jsx'; |
| 27 | import DetailsCatalogView from 'sdc-app/onboarding/onboard/DetailsCatalogView.jsx'; |
| 28 | |
| 29 | describe('OnBoarding Catalog test - View: ', function () { |
| 30 | |
| 31 | |
| 32 | it('mapStateToProps mapper exists', () => { |
| 33 | expect(mapStateToProps).toBeTruthy(); |
| 34 | }); |
| 35 | |
| 36 | it('mapStateToProps data test', () => { |
| 37 | |
| 38 | const licenseModelList = FinalizedLicenseModelFactory.buildList(3); |
| 39 | const softwareProductList = VSPEditorFactory.buildList(4); |
| 40 | const data = defaultStoreFactory.build({licenseModelList, softwareProductList}); |
| 41 | |
| 42 | var results = mapStateToProps(data); |
| 43 | expect(results.softwareProductList).toBeTruthy(); |
| 44 | expect(results.licenseModelList).toBeTruthy(); |
| 45 | expect(results.activeTab).toBeTruthy(); |
| 46 | expect(results.licenseModelList.length).toEqual(3); |
| 47 | }); |
| 48 | |
| 49 | it('licenseModelList creating algorithm test', () => { |
| 50 | |
| 51 | const finalizedLicenseModelList = FinalizedLicenseModelFactory.buildList(3); |
| 52 | const licenseModelList = [...finalizedLicenseModelList]; |
| 53 | const finalizedSoftwareProductList = VSPEditorFactory.buildList(4 ,{vendorId: finalizedLicenseModelList[0].id}); |
| 54 | const softwareProductList = [...finalizedSoftwareProductList]; |
| 55 | const data = defaultStoreFactory.build({licenseModelList, finalizedLicenseModelList, softwareProductList, finalizedSoftwareProductList}); |
| 56 | |
| 57 | var results = mapStateToProps(data); |
| 58 | expect(results.finalizedLicenseModelList[0].softwareProductList.length).toEqual(finalizedSoftwareProductList.length); |
| 59 | }); |
| 60 | |
| 61 | |
| 62 | it('Catalog view test', () => { |
| 63 | |
| 64 | const dummyFunc = () => {}; |
| 65 | const licenseModelList = FinalizedLicenseModelFactory.buildList(3); |
| 66 | const softwareProductList = VSPEditorFactory.buildList(4 ,{vendorId: licenseModelList[0].id}); |
| 67 | const data = defaultStoreFactory.build({licenseModelList, softwareProductList}); |
| 68 | |
| 69 | const func = { |
| 70 | onAddLicenseModelClick: dummyFunc, |
| 71 | onAddSoftwareProductClick: dummyFunc, |
| 72 | closeVspOverlay: dummyFunc, |
| 73 | onVspOverlayChange: dummyFunc, |
| 74 | onTabClick: dummyFunc, |
| 75 | onSearch: dummyFunc, |
| 76 | onSelectLicenseModel: dummyFunc, |
| 77 | onSelectSoftwareProduct: dummyFunc, |
| 78 | resetOnboardingCatalogStore: '' |
| 79 | }; |
| 80 | |
| 81 | let params = {...func, ...mapStateToProps(data)}; |
| 82 | let CatalogView = TestUtils.renderIntoDocument(<OnboardingCatalogView |
| 83 | {...params}/>); |
| 84 | expect(CatalogView).toBeTruthy(); |
| 85 | }); |
| 86 | |
| 87 | it('VendorItem view test', () => { |
| 88 | let vendor = FinalizedLicenseModelFactory.build(); |
| 89 | const dummyFunc = () => {}; |
| 90 | let params = { |
| 91 | softwareProductList: VSPEditorFactory.buildList(4 ,{vendorId: vendor.id}), |
| 92 | vendor, |
| 93 | onSelectVSP: dummyFunc, |
| 94 | shouldShowOverlay: false, |
| 95 | onVendorSelect: dummyFunc, |
| 96 | onAddVSP: dummyFunc, |
| 97 | onVSPIconClick: dummyFunc, |
| 98 | }; |
| 99 | |
| 100 | let VendorItemView = TestUtils.renderIntoDocument(<VendorItem{...params}/>); |
| 101 | expect(VendorItemView).toBeTruthy(); |
| 102 | }); |
| 103 | |
| 104 | |
| 105 | it('VSPOverlay view test', () => { |
| 106 | |
| 107 | let params = { |
| 108 | VSPList: VSPEditorFactory.buildList(10 ,{vendorId: '1'}), |
| 109 | onSelectVSP: () => {} |
| 110 | }; |
| 111 | |
| 112 | let VSPOverlayView = TestUtils.renderIntoDocument(<div><VSPOverlay {...params}/></div>); |
| 113 | expect(VSPOverlayView).toBeTruthy(); |
| 114 | }); |
| 115 | |
| 116 | it('CatalogItemDetails view test', () => { |
| 117 | |
| 118 | let params = { |
| 119 | catalogItemData: FinalizedLicenseModelFactory.build(), |
| 120 | onSelect: () => {}, |
| 121 | catalogItemTypeClass: '' |
| 122 | }; |
| 123 | |
| 124 | let CatalogItemDetailsView = TestUtils.renderIntoDocument(<div><CatalogItemDetails {...params}/></div>); |
| 125 | expect(CatalogItemDetailsView).toBeTruthy(); |
| 126 | }); |
| 127 | |
| 128 | it('DetailsCatalogView view test', () => { |
| 129 | |
| 130 | let params = { |
| 131 | VLMList: FinalizedLicenseModelFactory.buildList(3), |
| 132 | VSPList: VSPEditorFactory.buildList(4), |
| 133 | onSelectVLM: () => {}, |
| 134 | onSelectVSP: () => {}, |
| 135 | onAddVLM: () => {}, |
| 136 | onAddVSP: () => {}, |
| 137 | filter: '' |
| 138 | }; |
| 139 | |
| 140 | let AllCatalog = TestUtils.renderIntoDocument(<DetailsCatalogView {...params}/>); |
| 141 | expect(AllCatalog).toBeTruthy(); |
| 142 | }); |
| 143 | }); |