2 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 import React from 'react';
20 import TestUtils from 'react-addons-test-utils';
22 import {Provider} from 'react-redux';
23 import {storeCreator} from 'sdc-app/AppStore.js';
25 import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
26 import {CategoryWithSubFactory} from 'test-utils/factories/softwareProduct/VSPCategoriesFactory.js';
27 import {LicenseAgreementStoreFactory} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js';
28 import {FeatureGroupStoreFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js';
29 import {default as SoftwareProductQSchemaFactory} from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js';
30 import {default as VspQdataFactory} from 'test-utils/factories/softwareProduct/VspQdataFactory.js';
31 import {VSPComponentsFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js';
32 import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
33 import CurrentScreenFactory from 'test-utils/factories/common/CurrentScreenFactory.js';
35 import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js';
36 import SoftwareProductLandingPageView from 'sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx';
39 describe('Software Product Landing Page: ', function () {
41 let currentSoftwareProduct = {}, softwareProductCategories = [], currentScreen = {},
42 finalizedLicenseModelList, licenseAgreementList, featureGroupsList, qschema, qdata = {};
43 const dummyFunc = () => {};
45 beforeAll(function() {
46 finalizedLicenseModelList = FinalizedLicenseModelFactory.buildList(2);
47 currentSoftwareProduct = VSPEditorFactory.build({id:'RTRTG454545', vendorId: finalizedLicenseModelList[0].id, vendorName: finalizedLicenseModelList[0].name, onBoardingMethod: 'HEAT'});
48 softwareProductCategories = CategoryWithSubFactory.buildList(2,{},{quantity: 1});
49 licenseAgreementList = LicenseAgreementStoreFactory.buildList(2);
50 featureGroupsList = FeatureGroupStoreFactory.buildList(2,{referencingLicenseAgreements:[licenseAgreementList[0].id]});
51 currentScreen = CurrentScreenFactory.build();
52 qdata = VspQdataFactory.build();
53 qschema = SoftwareProductQSchemaFactory.build(qdata);
56 it('should mapper exist', () => {
57 expect(mapStateToProps).toBeTruthy();
60 it('should mapper return vsp basic data', () => {
64 softwareProductEditor: {
65 data: currentSoftwareProduct
67 softwareProductCategories,
68 softwareProductQuestionnaire: {
72 softwareProductComponents: {
75 softwareProductAttachments: {
79 finalizedLicenseModelList,
90 const result = mapStateToProps(state);
91 expect(result.currentSoftwareProduct).toBeTruthy();
95 it('vsp landing basic view', () => {
98 ...currentScreen.props,
99 currentSoftwareProduct,
100 componentsList: VSPComponentsFactory.buildList(2)
103 const store = storeCreator();
104 let vspLandingView = TestUtils.renderIntoDocument(
105 <Provider store={store}>
106 <SoftwareProductLandingPageView {...params}/>
109 expect(vspLandingView).toBeTruthy();
112 it('vsp landing handleOnDragEnter test ', () => {
115 currentSoftwareProduct,
116 ...currentScreen.props,
117 componentsList: VSPComponentsFactory.buildList(2)
120 const store = storeCreator();
121 let vspLandingView = TestUtils.renderIntoDocument(
122 <Provider store={store}>
123 <SoftwareProductLandingPageView {...params}/>
126 let vspLandingViewWrapper = TestUtils.findRenderedComponentWithType(
128 SoftwareProductLandingPageView
130 expect(vspLandingView).toBeTruthy();
131 vspLandingViewWrapper.handleOnDragEnter(false);
132 expect(vspLandingViewWrapper.state.dragging).toEqual(true);
136 it('vsp landing handleImportSubmit test ', () => {
139 ...currentScreen.props,
140 currentSoftwareProduct,
141 componentsList: VSPComponentsFactory.buildList(2),
142 onUploadConfirmation: dummyFunc,
144 onInvalidFileSizeUpload: dummyFunc
154 const store = storeCreator();
156 let vspLandingView = TestUtils.renderIntoDocument(
157 <Provider store={store}>
158 <SoftwareProductLandingPageView {...params}/>
162 let vspLandingViewWrapper = TestUtils.findRenderedComponentWithType(
164 SoftwareProductLandingPageView
166 expect(vspLandingView).toBeTruthy();
167 vspLandingViewWrapper.handleImportSubmit(files, false);
168 expect(vspLandingViewWrapper.state.dragging).toEqual(false);
169 expect(vspLandingViewWrapper.state.fileName).toEqual(files[0].name);
176 vspLandingViewWrapper.handleImportSubmit(files1, false);
179 it('vsp landing handleImportSubmit with damaged file test ', () => {
182 currentSoftwareProduct,
183 ...currentScreen.props,
184 componentsList: VSPComponentsFactory.buildList(2),
185 onUploadConfirmation: dummyFunc,
187 onInvalidFileSizeUpload: dummyFunc
190 const store = storeCreator();
192 let vspLandingView = TestUtils.renderIntoDocument(
193 <Provider store={store}>
194 <SoftwareProductLandingPageView {...params}/>
198 let vspLandingViewWrapper = TestUtils.findRenderedComponentWithType(
200 SoftwareProductLandingPageView
202 expect(vspLandingView).toBeTruthy();
210 vspLandingViewWrapper.handleImportSubmit(files, false);
211 expect(vspLandingViewWrapper.state.dragging).toEqual(false);
212 expect(vspLandingViewWrapper.state.fileName).toEqual('');