react-version-downgrade
[sdc.git] / openecomp-ui / test / licenseModel / overview / listItems / FeatureGroup.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-addons-test-utils';
19 import FeatureGroup from 'src/sdc-app/onboarding/licenseModel/overview/listItems/FeatureGroup.jsx';
20 import {scryRenderedDOMComponentsWithTestId} from 'test-utils/Util.js';
21 import {FeatureGroupListItemFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js';
22 import {EntitlementPoolListItemFactory} from 'test-utils/factories/licenseModel/EntitlementPoolFactories.js';
23 import {LicenseKeyGroupListItemFactory} from 'test-utils/factories/licenseModel/LicenseKeyGroupFactories.js';
24
25 describe('Feature Group List Item Module Tests', function () {
26         it('Feature Group List Item should exist', () => {
27                 expect(FeatureGroup).toBeTruthy();
28         });
29
30         it('renders Feature Group List Item Collapsed', () => {
31                 const fgData =  FeatureGroupListItemFactory.build();
32                 const itemView = TestUtils.renderIntoDocument( <FeatureGroup fgData={fgData} /> );
33                 expect(itemView).toBeTruthy();
34                 const elem = TestUtils.scryRenderedDOMComponentsWithClass(itemView,'down');
35                 expect(elem).toBeTruthy();
36         });
37
38         it('renders Feature Group List Item Expanded', () => {
39                 const fgData =  FeatureGroupListItemFactory.build({isCollpased: false});
40                 const itemView = TestUtils.renderIntoDocument( <FeatureGroup fgData={fgData} /> );
41                 expect(itemView).toBeTruthy();
42                 const elem = TestUtils.scryRenderedDOMComponentsWithClass(itemView,'right');
43                 expect(elem).toBeTruthy();
44         });
45
46         it('renders Feature Group List Item with Children Count', () => {
47                 const children = [EntitlementPoolListItemFactory.build(), LicenseKeyGroupListItemFactory.build()];
48                 const fgData =  FeatureGroupListItemFactory.build({children: children, isCollpased: false});
49                 const itemView = TestUtils.renderIntoDocument( <FeatureGroup fgData={fgData} /> );
50                 expect(itemView).toBeTruthy();
51                 let elem = scryRenderedDOMComponentsWithTestId(itemView,'vlm-list-ep-count-value');
52                 expect(elem).toBeTruthy();
53                 expect(elem[0].innerHTML).toBe('1');
54                 elem = scryRenderedDOMComponentsWithTestId(itemView,'vlm-list-lkg-count-value');
55                 expect(elem).toBeTruthy();
56                 expect(elem[0].innerHTML).toBe('1');
57         });
58 });