blob: f8cff418e0cf7c5971b9bfdcaea41a6975a7b0d8 [file] [log] [blame]
svishnev1eb66b72018-01-11 14:39:45 +02001/*
2 * Copyright © 2016-2017 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
svishnev1eb66b72018-01-11 14:39:45 +02007 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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';
svishnevaa2eece2018-01-18 17:52:06 +020018import TestUtils from 'react-addons-test-utils';
AviZi280f8012017-06-09 02:39:56 +030019import {defaultStoreFactory} from 'test-utils/factories/onboard/OnboardingCatalogFactories.js';
20import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
21import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
22import {mapStateToProps} from 'sdc-app/onboarding/onboard/Onboard.js';
talig8e9c0652017-12-20 14:30:43 +020023import {catalogItemTypes} from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogConstants.js';
AviZi280f8012017-06-09 02:39:56 +030024import OnboardingCatalogView from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogView.jsx';
25import VendorItem from 'sdc-app/onboarding/onboard/onboardingCatalog/VendorItem.jsx';
26import VSPOverlay from 'sdc-app/onboarding/onboard/onboardingCatalog/VSPOverlay.jsx';
27import CatalogItemDetails from 'sdc-app/onboarding/onboard/CatalogItemDetails.jsx';
28import DetailsCatalogView from 'sdc-app/onboarding/onboard/DetailsCatalogView.jsx';
29
30describe('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);
talig8e9c0652017-12-20 14:30:43 +020053 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});
AviZi280f8012017-06-09 02:39:56 +030056 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);
talig8e9c0652017-12-20 14:30:43 +020067 const softwareProductList = VSPEditorFactory.buildList(4, {vendorId: licenseModelList[0].id});
AviZi280f8012017-06-09 02:39:56 +030068 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: () => {},
talig8e9c0652017-12-20 14:30:43 +0200122 catalogItemTypeClass: catalogItemTypes.LICENSE_MODEL
AviZi280f8012017-06-09 02:39:56 +0300123 };
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});