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 {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
23 import {CategoryWithSubFactory} from 'test-utils/factories/softwareProduct/VSPCategoriesFactory.js';
24 import {LicenseAgreementStoreFactory} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js';
25 import {FeatureGroupStoreFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js';
26 import {default as SoftwareProductQSchemaFactory} from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js';
27 import {default as VspQdataFactory} from 'test-utils/factories/softwareProduct/VspQdataFactory.js';
28 import {VSPComponentsFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js';
29 import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
31 import { Provider } from 'react-redux';
32 import {storeCreator} from 'sdc-app/AppStore.js';
34 import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js';
35 import SoftwareProductLandingPageView from 'sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx';
38 describe('Software Product Landing Page: ', function () {
40 let currentSoftwareProduct = {}, softwareProductCategories = [],
41 finalizedLicenseModelList, licenseAgreementList, featureGroupsList, qschema, qdata = {};
42 const dummyFunc = () => {};
43 beforeAll(function() {
44 finalizedLicenseModelList = FinalizedLicenseModelFactory.buildList(2);
45 currentSoftwareProduct = VSPEditorFactory.build({id:'RTRTG454545', vendorId: finalizedLicenseModelList[0].id, vendorName: finalizedLicenseModelList[0].name});
46 softwareProductCategories = CategoryWithSubFactory.buildList(2,{},{quantity: 1});
47 licenseAgreementList = LicenseAgreementStoreFactory.buildList(2);
48 featureGroupsList = FeatureGroupStoreFactory.buildList(2,{referencingLicenseAgreements:[licenseAgreementList[0].id]});
49 qdata = VspQdataFactory.build();
50 qschema = SoftwareProductQSchemaFactory.build(qdata);
56 it('should mapper exist', () => {
57 expect(mapStateToProps).toBeTruthy();
60 it('should mapper return vsp basic data', () => {
63 softwareProductEditor: {
64 data: currentSoftwareProduct
66 softwareProductCategories,
67 softwareProductQuestionnaire: {
71 softwareProductComponents: {
75 finalizedLicenseModelList,
86 const result = mapStateToProps(obj);
87 expect(result.currentSoftwareProduct).toBeTruthy();
88 expect(result.isReadOnlyMode).toEqual(true);
92 it('vsp landing basic view', () => {
95 currentSoftwareProduct,
96 isReadOnlyMode: false,
97 componentsList: VSPComponentsFactory.buildList(2)
100 const store = storeCreator();
101 let vspLandingView = TestUtils.renderIntoDocument(<Provider store={store}><SoftwareProductLandingPageView
102 {...params}/></Provider>);
103 expect(vspLandingView).toBeTruthy();
106 it('vsp landing handleOnDragEnter test ', () => {
109 currentSoftwareProduct,
110 isReadOnlyMode: false,
111 componentsList: VSPComponentsFactory.buildList(2)
114 const store = storeCreator();
115 let vspLandingView = TestUtils.renderIntoDocument(<Provider store={store}><SoftwareProductLandingPageView
116 {...params}/></Provider>);
117 let vspLandingViewWrapper = TestUtils.findRenderedComponentWithType(
119 SoftwareProductLandingPageView
121 expect(vspLandingView).toBeTruthy();
122 vspLandingViewWrapper.handleOnDragEnter(false);
123 expect(vspLandingViewWrapper.state.dragging).toEqual(true);
127 it('vsp landing handleImportSubmit test ', () => {
130 currentSoftwareProduct,
131 isReadOnlyMode: false,
132 componentsList: VSPComponentsFactory.buildList(2),
133 onUploadConfirmation: dummyFunc,
135 onInvalidFileSizeUpload: dummyFunc
145 const store = storeCreator();
147 let vspLandingView = TestUtils.renderIntoDocument(<Provider store={store}><SoftwareProductLandingPageView {...params}/></Provider>);
148 let vspLandingViewWrapper = TestUtils.findRenderedComponentWithType(
150 SoftwareProductLandingPageView
152 expect(vspLandingView).toBeTruthy();
153 vspLandingViewWrapper.handleImportSubmit(files, false);
154 expect(vspLandingViewWrapper.state.dragging).toEqual(false);
155 expect(vspLandingViewWrapper.state.fileName).toEqual(files[0].name);
162 vspLandingViewWrapper.handleImportSubmit(files1, false);
165 it('vsp landing handleImportSubmit with damaged file test ', () => {
168 currentSoftwareProduct,
169 isReadOnlyMode: false,
170 componentsList: VSPComponentsFactory.buildList(2),
171 onUploadConfirmation: dummyFunc,
173 onInvalidFileSizeUpload: dummyFunc
176 const store = storeCreator();
178 let vspLandingView = TestUtils.renderIntoDocument(<Provider store={store}><SoftwareProductLandingPageView
179 {...params}/></Provider>);
181 let vspLandingViewWrapper = TestUtils.findRenderedComponentWithType(
183 SoftwareProductLandingPageView
185 expect(vspLandingView).toBeTruthy();
193 vspLandingViewWrapper.handleImportSubmit(files, false);
194 expect(vspLandingViewWrapper.state.dragging).toEqual(false);
195 expect(vspLandingViewWrapper.state.fileName).toEqual('');