[SDC-29] Amdocs OnBoard 1707 initial commit.
[sdc.git] / openecomp-ui / test / licenseModel / overview / summary / SummaryCountList.test.js
1 /*!
2  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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
13  * or implied. See the License for the specific language governing
14  * permissions and limitations under the License.
15  */
16
17 import React from 'react';
18 import TestUtils from 'react-addons-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.isReadOnlyMode).toEqual(true);
59                 expect(result.description).toEqual(obj.licenseModel.licenseModelEditor.data.description);
60                 expect(result.counts).toEqual(counts);
61         });
62
63         it('jsx view test', () => {
64
65                 var counts = [
66                         {name: overviewItems.LICENSE_AGREEMENTS, count: 0},
67                         {name: overviewItems.FEATURE_GROUPS, count: 0},
68                         {name: overviewItems.ENTITLEMENT_POOLS, count: 0},
69                         {name: overviewItems.LICENSE_KEY_GROUPS, count: 0},
70                 ];
71
72                 var view = TestUtils.renderIntoDocument(<SummaryCountList counts={counts} licenseModelId='1' isReadOnlyMode={false}/>);
73                 expect(view).toBeTruthy();
74         });
75
76         it('description editor jsx view test', () => {
77                 var data = LicenseModelStoreFactory.build();
78                 var genericFieldInfo = {
79                         description: {
80                                 isValid : true
81                         }
82                 }
83                 var view = TestUtils.renderIntoDocument(<LicenseModelDescriptionEdit data={data} genericFieldInfo={genericFieldInfo} description='desc'/>);
84                 expect(view).toBeTruthy();
85         });
86
87 });