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