2 * Copyright © 2016-2017 European Support Limited
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 or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 import React from 'react';
18 import TestUtils from 'react-addons-test-utils';
19 import {mapStateToProps, mapActionsToProps} from 'sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreation.js';
20 import SoftwareProductCreationView from 'sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationView.jsx';
21 import {SoftwareProductCreationFactory, SoftwareProductCreationFactoryWithSelectedVendor} from 'test-utils/factories/softwareProduct/SoftwareProductCreationFactories.js';
22 import {CategoryWithSubFactory} from 'test-utils/factories/softwareProduct/VSPCategoriesFactory.js';
23 import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
24 import {storeCreator} from 'sdc-app/AppStore.js';
26 describe('Software Product Creation Module Tests', function() {
27 it ('mapStateToProps mapper exists', () => {
28 expect(mapStateToProps).toBeTruthy();
31 it ('should return empty data', () => {
33 softwareProductList: [],
35 softwareProductCreation: {
43 let props = mapStateToProps(state);
44 expect(props.data).toEqual({});
47 it ('should return vsp names list', () => {
49 softwareProductList: [{
57 softwareProductCreation: {
65 let props = mapStateToProps(state);
66 expect(props.data).toEqual({});
67 expect(props.VSPNames).toEqual({vsp1: 'vsp1_id', vsp2: 'vsp2_id'});
70 it('simple jsx test', () => {
71 const store = storeCreator();
72 let dispatch = store.dispatch;
75 softwareProductList: [],
77 softwareProductCreation: SoftwareProductCreationFactory.build(),
78 softwareProductCategories: CategoryWithSubFactory.buildList({}, {quantity: 2})
80 finalizedLicenseModelList: FinalizedLicenseModelFactory.buildList(3),
85 let props = Object.assign({}, mapStateToProps(state), mapActionsToProps(dispatch));
86 var renderer = TestUtils.createRenderer();
88 <SoftwareProductCreationView {...props}/>
90 var renderedOutput = renderer.getRenderOutput();
91 expect(renderedOutput).toBeTruthy();
94 it('simple jsx test - with selected vendor', () => {
95 const store = storeCreator();
96 let dispatch = store.dispatch;
97 let finalizedLicenseModelList = FinalizedLicenseModelFactory.buildList(3);
99 softwareProductList: [],
101 softwareProductCreation: SoftwareProductCreationFactoryWithSelectedVendor.build({selectedVendorId: finalizedLicenseModelList[0].id}),
102 softwareProductCategories: CategoryWithSubFactory.buildList({}, {quantity: 2})
104 finalizedLicenseModelList,
109 let props = Object.assign({}, mapStateToProps(state), mapActionsToProps(dispatch));
110 var renderer = TestUtils.createRenderer();
112 <SoftwareProductCreationView {...props}/>
114 let renderedOutput = renderer.getRenderOutput();
115 expect(renderedOutput).toBeTruthy();