2f0bbfa6610c1de33e7ac187c59e85cf28ee805c
[sdc.git] / openecomp-ui / test / licenseModel / overview / summary / SummaryCountList.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
20 import {mapStateToProps, SummaryCountList} from 'sdc-app/onboarding/licenseModel/overview/summary/SummaryCountList.js';
21 import LicenseModelDescriptionEdit from 'sdc-app/onboarding/licenseModel/overview/summary/LicenseModelDescriptionEdit.jsx';
22 import {overviewItems} from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js';
23 import {LicenseModelOverviewFactory, LicenseModelStoreFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
24
25 describe('License Model Overview Summary Count List module test', () => {
26
27         it('should mapper exist', () => {
28                 expect(mapStateToProps).toBeTruthy();
29         });
30
31         it('mapper data return test',() => {
32
33                 var obj = {
34                         licenseModel: LicenseModelOverviewFactory.build({
35                                 entitlementPool: {
36                                         entitlementPoolsList: []
37                                 },
38                                 licenseAgreement: {
39                                         licenseAgreementList: []
40                                 },
41                                 featureGroup: {
42                                         featureGroupsList: []
43                                 },
44                                 licenseKeyGroup: {
45                                         licenseKeyGroupsList: []
46                                 }
47                         })
48                 };
49
50                 let counts = [
51                         {name: overviewItems.LICENSE_AGREEMENTS, count: 0},
52                         {name: overviewItems.FEATURE_GROUPS, count: 0},
53                         {name: overviewItems.ENTITLEMENT_POOLS, count: 0},
54                         {name: overviewItems.LICENSE_KEY_GROUPS, count: 0},
55                 ];
56
57                 var result = mapStateToProps(obj);
58                 expect(result.description).toEqual(obj.licenseModel.licenseModelEditor.data.description);
59                 expect(result.counts).toEqual(counts);
60         });
61
62         it('jsx view test', () => {
63
64                 var counts = [
65                         {name: overviewItems.LICENSE_AGREEMENTS, count: 0},
66                         {name: overviewItems.FEATURE_GROUPS, count: 0},
67                         {name: overviewItems.ENTITLEMENT_POOLS, count: 0},
68                         {name: overviewItems.LICENSE_KEY_GROUPS, count: 0},
69                 ];
70
71                 var view = TestUtils.renderIntoDocument(<SummaryCountList counts={counts} licenseModelId='1' isReadOnlyMode={false}/>);
72                 expect(view).toBeTruthy();
73         });
74
75         it('description editor jsx view test', () => {
76                 var data = LicenseModelStoreFactory.build();
77                 var genericFieldInfo = {
78                         description: {
79                                 isValid : true
80                         }
81                 };
82                 var view = TestUtils.renderIntoDocument(<LicenseModelDescriptionEdit data={data} genericFieldInfo={genericFieldInfo} description='desc'/>);
83                 expect(view).toBeTruthy();
84         });
85
86 });