2 * Copyright © 2016-2017 European Support Limited
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 import React from 'react';
18 import TestUtils from 'react-dom/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';
25 describe('Feature Group List Item Module Tests', function () {
26 it('Feature Group List Item should exist', () => {
27 expect(FeatureGroup).toBeTruthy();
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();
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();
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');