react 16 upgrade
[sdc.git] / openecomp-ui / test / licenseModel / featureGroups / LicenseModelFeatureGroupListEditor.test.js
1 /*
2  * Copyright © 2016-2018 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     it('should mapper exist', () => {
28         expect(mapStateToProps).toBeTruthy();
29     });
30
31     it('should return empty data', () => {
32         let licenseModel = LicenseModelOverviewFactory.build({
33             featureGroup: {
34                 featureGroupEditor: {},
35                 featureGroupsList: []
36             },
37             licenseModelEditor: {
38                 data: {
39                     ...VersionControllerUtilsFactory.build()
40                 }
41             }
42         });
43         var results = mapStateToProps({ licenseModel });
44         expect(results.vendorName).toEqual(undefined);
45         expect(results.featureGroupsList).toEqual([]);
46     });
47
48     it('should return true for show and edit mode and vendorName should be not empty', () => {
49         let licenseModel = LicenseModelOverviewFactory.build({
50             featureGroup: {
51                 featureGroupEditor: {
52                     data: FeatureGroupStoreFactory.build()
53                 },
54                 featureGroupsList: []
55             }
56         });
57         var results = mapStateToProps({ licenseModel });
58         expect(results.vendorName).toEqual(
59             licenseModel.licenseModelEditor.data.vendorName
60         );
61     });
62
63     it('jsx view test', () => {
64         var view = TestUtils.renderIntoDocument(
65             <FeatureGroupsListEditorView
66                 vendorName=""
67                 licenseModelId=""
68                 isReadOnlyMode={false}
69                 onAddFeatureGroupClick={() => {}}
70                 featureGroupsList={[]}
71             />
72         );
73         expect(view).toBeTruthy();
74     });
75
76     it('jsx view list test', () => {
77         var view = TestUtils.renderIntoDocument(
78             <FeatureGroupsListEditorView
79                 vendorName=""
80                 licenseModelId=""
81                 isReadOnlyMode={false}
82                 onAddFeatureGroupClick={() => {}}
83                 featureGroupsList={buildListFromFactory(
84                     FeatureGroupStoreFactory
85                 )}
86             />
87         );
88         expect(view).toBeTruthy();
89     });
90 });