976d9888001b8fa0a92c07e3855dbd1eec25fbca
[sdc.git] / openecomp-ui / test / licenseModel / featureGroups / LicenseModelFeatureGroupListEditor.test.js
1 /*
2  * Copyright © 2016-2017 European Support Limited
3  *
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
7  * 
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  * 
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.
15  */
16
17 import React from 'react';
18 import TestUtils from 'react-dom/test-utils';
19 import {mapStateToProps} from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditor.js';
20 import FeatureGroupsListEditorView from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditorView.jsx';
21 import { FeatureGroupStoreFactory } from 'test-utils/factories/licenseModel/FeatureGroupFactories.js';
22 import {LicenseModelOverviewFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
23 import { buildListFromFactory } from 'test-utils/Util.js';
24 import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
25
26 describe('License Model  Feature Group List  Module Tests', function () {
27
28         it('should mapper exist', () => {
29                 expect(mapStateToProps).toBeTruthy();
30         });
31
32
33         it('should return empty data', () => {
34
35
36                 let licenseModel = LicenseModelOverviewFactory.build({
37                         featureGroup: {
38                                 featureGroupEditor: {},
39                                 featureGroupsList: []
40                         },
41                         licenseModelEditor: {
42                                 data:{
43                                         ...VersionControllerUtilsFactory.build()
44                                 }
45                         }
46                 });
47                 var results = mapStateToProps({licenseModel});
48                 expect(results.vendorName).toEqual(undefined);
49                 expect(results.featureGroupsModal.show).toEqual(false);
50                 expect(results.featureGroupsModal.editMode).toEqual(false);
51                 expect(results.featureGroupsList).toEqual([]);
52         });
53
54         it('should return true for show and edit mode and vendorName should be not empty', () => {
55
56                 let licenseModel = LicenseModelOverviewFactory.build({
57                         featureGroup: {
58                                 featureGroupEditor: {
59                                         data: FeatureGroupStoreFactory.build()
60                                 },
61                                 featureGroupsList: []
62                         }
63                 });
64                 var results = mapStateToProps({licenseModel});
65                 expect(results.featureGroupsModal.show).toEqual(true);
66                 expect(results.featureGroupsModal.editMode).toEqual(true);
67                 expect(results.vendorName).toEqual(licenseModel.licenseModelEditor.data.vendorName);
68         });
69
70         it('jsx view test', () => {
71                 var view = TestUtils.renderIntoDocument(<FeatureGroupsListEditorView  vendorName=''
72                         licenseModelId=''
73                         featureGroupsModal={{show: false, editMode: false}}
74                         isReadOnlyMode={false}
75                         onAddFeatureGroupClick={()=>{}}
76                         featureGroupsList={[]} />);
77                 expect(view).toBeTruthy();
78         });
79
80         it('jsx view list test', () => {
81                 var view = TestUtils.renderIntoDocument(<FeatureGroupsListEditorView  vendorName=''
82                         licenseModelId=''
83                         featureGroupsModal={{show: false, editMode: true}}
84                         isReadOnlyMode={false}
85                         onAddFeatureGroupClick={()=>{}}
86                         featureGroupsList={buildListFromFactory(FeatureGroupStoreFactory)} />);
87                 expect(view).toBeTruthy();
88         });
89
90 });