blob: 63b49aafab2763af66824672d276ad4e7fedfa31 [file] [log] [blame]
svishnev1eb66b72018-01-11 14:39:45 +02001/*
Einav Weiss Keidard2f57942018-02-14 14:00:07 +02002 * Copyright © 2016-2018 European Support Limited
AviZi280f8012017-06-09 02:39:56 +03003 *
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 Keidard2f57942018-02-14 14:00:07 +02007 *
svishnev1eb66b72018-01-11 14:39:45 +02008 * http://www.apache.org/licenses/LICENSE-2.0
Einav Weiss Keidard2f57942018-02-14 14:00:07 +02009 *
AviZi280f8012017-06-09 02:39:56 +030010 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
svishnev1eb66b72018-01-11 14:39:45 +020012 * 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.
AviZi280f8012017-06-09 02:39:56 +030015 */
16
17import React from 'react';
svishnev091edfd2018-03-19 12:15:19 +020018import {Provider} from 'react-redux';
19import {storeCreator} from 'sdc-app/AppStore.js';
20
Einav Weiss Keidard2f57942018-02-14 14:00:07 +020021import TestUtils from 'react-dom/test-utils';
AviZi280f8012017-06-09 02:39:56 +030022import {defaultStoreFactory} from 'test-utils/factories/onboard/OnboardingCatalogFactories.js';
23import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
24import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
25import {mapStateToProps} from 'sdc-app/onboarding/onboard/Onboard.js';
talig8e9c0652017-12-20 14:30:43 +020026import {catalogItemTypes} from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogConstants.js';
AviZi280f8012017-06-09 02:39:56 +030027import OnboardingCatalogView from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogView.jsx';
28import VendorItem from 'sdc-app/onboarding/onboard/onboardingCatalog/VendorItem.jsx';
29import VSPOverlay from 'sdc-app/onboarding/onboard/onboardingCatalog/VSPOverlay.jsx';
30import CatalogItemDetails from 'sdc-app/onboarding/onboard/CatalogItemDetails.jsx';
31import DetailsCatalogView from 'sdc-app/onboarding/onboard/DetailsCatalogView.jsx';
32
33describe('OnBoarding Catalog test - View: ', function () {
34
35
36 it('mapStateToProps mapper exists', () => {
37 expect(mapStateToProps).toBeTruthy();
38 });
39
40 it('mapStateToProps data test', () => {
41
42 const licenseModelList = FinalizedLicenseModelFactory.buildList(3);
43 const softwareProductList = VSPEditorFactory.buildList(4);
44 const data = defaultStoreFactory.build({licenseModelList, softwareProductList});
45
46 var results = mapStateToProps(data);
47 expect(results.softwareProductList).toBeTruthy();
48 expect(results.licenseModelList).toBeTruthy();
49 expect(results.activeTab).toBeTruthy();
50 expect(results.licenseModelList.length).toEqual(3);
51 });
52
53 it('licenseModelList creating algorithm test', () => {
54
55 const finalizedLicenseModelList = FinalizedLicenseModelFactory.buildList(3);
talig8e9c0652017-12-20 14:30:43 +020056 const licenseModelList = FinalizedLicenseModelFactory.buildList(3);
57 const finalizedSoftwareProductList = VSPEditorFactory.buildList(4, {vendorId: finalizedLicenseModelList[0].id});
58 const softwareProductList = VSPEditorFactory.buildList(4, {vendorId: finalizedLicenseModelList[1].id});
AviZi280f8012017-06-09 02:39:56 +030059 const data = defaultStoreFactory.build({licenseModelList, finalizedLicenseModelList, softwareProductList, finalizedSoftwareProductList});
60
61 var results = mapStateToProps(data);
62 expect(results.finalizedLicenseModelList[0].softwareProductList.length).toEqual(finalizedSoftwareProductList.length);
63 });
64
65
66 it('Catalog view test', () => {
67
68 const dummyFunc = () => {};
69 const licenseModelList = FinalizedLicenseModelFactory.buildList(3);
talig8e9c0652017-12-20 14:30:43 +020070 const softwareProductList = VSPEditorFactory.buildList(4, {vendorId: licenseModelList[0].id});
AviZi280f8012017-06-09 02:39:56 +030071 const data = defaultStoreFactory.build({licenseModelList, softwareProductList});
72
73 const func = {
74 onAddLicenseModelClick: dummyFunc,
75 onAddSoftwareProductClick: dummyFunc,
76 closeVspOverlay: dummyFunc,
77 onVspOverlayChange: dummyFunc,
78 onTabClick: dummyFunc,
79 onSearch: dummyFunc,
80 onSelectLicenseModel: dummyFunc,
81 onSelectSoftwareProduct: dummyFunc,
82 resetOnboardingCatalogStore: ''
83 };
84
85 let params = {...func, ...mapStateToProps(data)};
svishnev091edfd2018-03-19 12:15:19 +020086 const store = storeCreator();
87
88 let CatalogView = TestUtils.renderIntoDocument(
89 <Provider store={store}>
90 <OnboardingCatalogView
91 {...params}/>
92 </Provider>);
AviZi280f8012017-06-09 02:39:56 +030093 expect(CatalogView).toBeTruthy();
94 });
95
96 it('VendorItem view test', () => {
97 let vendor = FinalizedLicenseModelFactory.build();
98 const dummyFunc = () => {};
99 let params = {
100 softwareProductList: VSPEditorFactory.buildList(4 ,{vendorId: vendor.id}),
101 vendor,
102 onSelectVSP: dummyFunc,
103 shouldShowOverlay: false,
104 onVendorSelect: dummyFunc,
105 onAddVSP: dummyFunc,
106 onVSPIconClick: dummyFunc,
107 };
108
109 let VendorItemView = TestUtils.renderIntoDocument(<VendorItem{...params}/>);
110 expect(VendorItemView).toBeTruthy();
111 });
112
113
114 it('VSPOverlay view test', () => {
115
116 let params = {
117 VSPList: VSPEditorFactory.buildList(10 ,{vendorId: '1'}),
118 onSelectVSP: () => {}
119 };
120
121 let VSPOverlayView = TestUtils.renderIntoDocument(<div><VSPOverlay {...params}/></div>);
122 expect(VSPOverlayView).toBeTruthy();
123 });
124
125 it('CatalogItemDetails view test', () => {
126
127 let params = {
128 catalogItemData: FinalizedLicenseModelFactory.build(),
129 onSelect: () => {},
talig8e9c0652017-12-20 14:30:43 +0200130 catalogItemTypeClass: catalogItemTypes.LICENSE_MODEL
AviZi280f8012017-06-09 02:39:56 +0300131 };
132
133 let CatalogItemDetailsView = TestUtils.renderIntoDocument(<div><CatalogItemDetails {...params}/></div>);
134 expect(CatalogItemDetailsView).toBeTruthy();
135 });
136
137 it('DetailsCatalogView view test', () => {
138
139 let params = {
140 VLMList: FinalizedLicenseModelFactory.buildList(3),
141 VSPList: VSPEditorFactory.buildList(4),
142 onSelectVLM: () => {},
143 onSelectVSP: () => {},
144 onAddVLM: () => {},
145 onAddVSP: () => {},
146 filter: ''
147 };
148
149 let AllCatalog = TestUtils.renderIntoDocument(<DetailsCatalogView {...params}/>);
150 expect(AllCatalog).toBeTruthy();
151 });
152});