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';
32 import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js';
33 import SoftwareProductLandingPageView from 'sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx';
36 describe('Software Product Landing Page: ', function () {
38 let currentSoftwareProduct = {}, softwareProductCategories = [],
39 finalizedLicenseModelList, licenseAgreementList, featureGroupsList, qschema, qdata = {};
40 const dummyFunc = () => {};
41 beforeAll(function() {
42 finalizedLicenseModelList = FinalizedLicenseModelFactory.buildList(2);
43 currentSoftwareProduct = VSPEditorFactory.build({id:'RTRTG454545', vendorId: finalizedLicenseModelList[0].id, vendorName: finalizedLicenseModelList[0].name});
44 softwareProductCategories = CategoryWithSubFactory.buildList(2,{},{quantity: 1});
45 licenseAgreementList = LicenseAgreementStoreFactory.buildList(2);
46 featureGroupsList = FeatureGroupStoreFactory.buildList(2,{referencingLicenseAgreements:[licenseAgreementList[0].id]});
47 qdata = VspQdataFactory.build();
48 qschema = SoftwareProductQSchemaFactory.build(qdata);
54 it('should mapper exist', () => {
55 expect(mapStateToProps).toBeTruthy();
58 it('should mapper return vsp basic data', () => {
61 softwareProductEditor: {
62 data: currentSoftwareProduct
64 softwareProductCategories,
65 softwareProductQuestionnaire: {
69 softwareProductComponents: {
73 finalizedLicenseModelList,
84 const result = mapStateToProps(obj);
85 expect(result.currentSoftwareProduct).toBeTruthy();
86 expect(result.isReadOnlyMode).toEqual(true);
90 it('vsp landing basic view', () => {
93 currentSoftwareProduct,
94 isReadOnlyMode: false,
95 componentsList: VSPComponentsFactory.buildList(2)
98 let vspLandingView = TestUtils.renderIntoDocument(<SoftwareProductLandingPageView
100 expect(vspLandingView).toBeTruthy();
103 it('vsp landing handleOnDragEnter test ', () => {
106 currentSoftwareProduct,
107 isReadOnlyMode: false,
108 componentsList: VSPComponentsFactory.buildList(2)
111 let vspLandingView = TestUtils.renderIntoDocument(<SoftwareProductLandingPageView
113 expect(vspLandingView).toBeTruthy();
114 vspLandingView.handleOnDragEnter(false);
115 expect(vspLandingView.state.dragging).toEqual(true);
119 it('vsp landing handleImportSubmit test ', () => {
122 currentSoftwareProduct,
123 isReadOnlyMode: false,
124 componentsList: VSPComponentsFactory.buildList(2),
125 onUploadConfirmation: dummyFunc,
127 onInvalidFileSizeUpload: dummyFunc
130 let vspLandingView = TestUtils.renderIntoDocument(<SoftwareProductLandingPageView
132 expect(vspLandingView).toBeTruthy();
140 vspLandingView.handleImportSubmit(files, false);
141 expect(vspLandingView.state.dragging).toEqual(false);
142 expect(vspLandingView.state.fileName).toEqual(files[0].name);
149 vspLandingView.handleImportSubmit(files1, false);
152 it('vsp landing handleImportSubmit with damaged file test ', () => {
155 currentSoftwareProduct,
156 isReadOnlyMode: false,
157 componentsList: VSPComponentsFactory.buildList(2),
158 onUploadConfirmation: dummyFunc,
160 onInvalidFileSizeUpload: dummyFunc
163 let vspLandingView = TestUtils.renderIntoDocument(<SoftwareProductLandingPageView
165 expect(vspLandingView).toBeTruthy();
173 vspLandingView.handleImportSubmit(files, false);
174 expect(vspLandingView.state.dragging).toEqual(false);
175 expect(vspLandingView.state.fileName).toEqual('');