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.
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: {
40 let props = mapStateToProps(state);
41 expect(props.data).toEqual({});
44 it ('should return vsp names list', () => {
46 softwareProductList: [{
54 softwareProductCreation: {
59 let props = mapStateToProps(state);
60 expect(props.data).toEqual({});
61 expect(props.VSPNames).toEqual({vsp1: 'vsp1_id', vsp2: 'vsp2_id'});
64 it('simple jsx test', () => {
65 const store = storeCreator();
66 let dispatch = store.dispatch;
69 softwareProductList: [],
71 softwareProductCreation: SoftwareProductCreationFactory.build(),
72 softwareProductCategories: CategoryWithSubFactory.buildList({}, {quantity: 2})
74 finalizedLicenseModelList: FinalizedLicenseModelFactory.buildList(3)
76 let props = Object.assign({}, mapStateToProps(state), mapActionsToProps(dispatch));
77 var renderer = TestUtils.createRenderer();
79 <SoftwareProductCreationView {...props}/>
81 var renderedOutput = renderer.getRenderOutput();
82 expect(renderedOutput).toBeTruthy();
85 it('simple jsx test - with selected vendor', () => {
86 const store = storeCreator();
87 let dispatch = store.dispatch;
88 let finalizedLicenseModelList = FinalizedLicenseModelFactory.buildList(3);
90 softwareProductList: [],
92 softwareProductCreation: SoftwareProductCreationFactoryWithSelectedVendor.build({selectedVendorId: finalizedLicenseModelList[0].id}),
93 softwareProductCategories: CategoryWithSubFactory.buildList({}, {quantity: 2})
95 finalizedLicenseModelList
97 let props = Object.assign({}, mapStateToProps(state), mapActionsToProps(dispatch));
98 let renderer = TestUtils.createRenderer();
100 <SoftwareProductCreationView {...props}/>
102 let renderedOutput = renderer.getRenderOutput();
103 expect(renderedOutput).toBeTruthy();