blob: cee34145a8f22ce493a622f770303b708b887663 [file] [log] [blame]
AviZi280f8012017-06-09 02:39:56 +03001/*!
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
17import React from 'react';
18import TestUtils from 'react-addons-test-utils';
19import {scryRenderedDOMComponentsWithTestId} from 'test-utils/Util.js';
20import SummaryView from 'sdc-app/onboarding/licenseModel/overview/SummaryView.jsx';
21import LicenseModelOverviewView from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewView.jsx';
22import VLMListView from 'sdc-app/onboarding/licenseModel/overview/VLMListView.jsx';
23import {selectedButton} from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js';
24
25import {FeatureGroupListItemFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js';
26import {EntitlementPoolListItemFactory} from 'test-utils/factories/licenseModel/EntitlementPoolFactories.js';
27import {LicenseKeyGroupListItemFactory} from 'test-utils/factories/licenseModel/LicenseKeyGroupFactories.js';
28import {LicenseAgreementListItemFactory} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js';
29
30describe('License Model Overview - View: ', function () {
31
32 const lkgChild = LicenseKeyGroupListItemFactory.build();
33
34 const epChild = EntitlementPoolListItemFactory.build();
35
36 const baseFGData = FeatureGroupListItemFactory.build({isCollapsed: false});
37 const baseLAData = LicenseAgreementListItemFactory.build({isCollapse: false});
38
39 it('should render SummaryView', () => {
40 var renderer = TestUtils.createRenderer();
41 renderer.render(
42 <SummaryView />
43 );
44 let renderedOutput = renderer.getRenderOutput();
45 expect(renderedOutput).toBeTruthy();
46 });
47
48 it('should render LicenseModelOverviewView', () => {
49 let fgData = {...baseFGData};
50 fgData.children = Array.of(epChild, lkgChild);
51 let laData = {...baseLAData};
52 laData.children = [fgData];
53
54 const params = {
55 licenseModelId: 'VLM1',
56 isDisplayModal: false,
57 modalHeader: undefined,
58 licensingDataList: [laData],
ilanapc6a41de2017-11-07 11:54:10 +020059 orphanDataList: [],
AviZi280f8012017-06-09 02:39:56 +030060 selectedTab: selectedButton.VLM_LIST_VIEW,
61 onTabSelect: () => {}
62 };
63 var renderer = TestUtils.createRenderer();
64 renderer.render(
65 <LicenseModelOverviewView {...params}/>
66 );
67 let renderedOutput = renderer.getRenderOutput();
68 expect(renderedOutput).toBeTruthy();
69 });
70
71
72 it('should render empty VLMListView', () => {
73 const listview = TestUtils.renderIntoDocument( <VLMListView /> );
74 expect(listview).toBeTruthy();
75 const elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list');
76 expect(elem).toBeTruthy();
77 expect(elem[0].children.length).toBe(0);
78 });
79
80 it('should render VLMListView with licenseAgreement', () => {
81 const listview = TestUtils.renderIntoDocument( <VLMListView licensingDataList={[baseLAData]}/> );
82 expect(listview).toBeTruthy();
83 let elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list');
84 expect(elem).toBeTruthy();
85 expect(elem[0].children.length).toBe(1);
86 elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-la-item');
87 expect(elem).toBeTruthy();
88 expect(elem.length).toBe(1);
89 });
90
91 it('should render VLMListView with Feature Group', () => {
92 let laData = {...baseLAData};
93 laData.children = [baseFGData];
94 const listview = TestUtils.renderIntoDocument( <VLMListView licensingDataList={[laData]}/> );
95 expect(listview).toBeTruthy();
96 const elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-fg');
97 expect(elem).toBeTruthy();
98 expect(elem.length).toBe(1);
99 });
100
101 it('should render VLMListView with Entitlement Pool', () => {
102 let fgData = {...baseFGData};
103 fgData.children = [epChild];
104 let laData = {...baseLAData};
105 laData.children = [fgData];
106
107 const listview = TestUtils.renderIntoDocument( <VLMListView licensingDataList={[laData]} showInUse={true} /> );
108 expect(listview).toBeTruthy();
109 const elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-ep');
110 expect(elem).toBeTruthy();
111 expect(elem.length).toBe(1);
112 });
113
114 it('should render VLMListView with LicenseKeyGroup', () => {
115 let fgData = {...baseFGData};
116 fgData.children = [lkgChild];
117 let laData = {...baseLAData};
118 laData.children = [fgData];
119
120 const listview = TestUtils.renderIntoDocument( <VLMListView licensingDataList={[laData]} showInUse={true} /> );
121 expect(listview).toBeTruthy();
122 const elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-lkg');
123 expect(elem).toBeTruthy();
124 expect(elem.length).toBe(1);
125 });
126
127 it('should render VLMListView with all items', () => {
128 let fgData = {...baseFGData};
129 fgData.children = Array.of(epChild, lkgChild);
130 let laData = {...baseLAData};
131 laData.children = [fgData];
132
133 const listview = TestUtils.renderIntoDocument( <VLMListView licensingDataList={[laData]} showInUse={true} /> );
134 expect(listview).toBeTruthy();
135 let elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-fg');
136 expect(elem).toBeTruthy();
137 expect(elem.length).toBe(1);
138 elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-lkg');
139 expect(elem).toBeTruthy();
140 expect(elem.length).toBe(1);
141 elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-ep');
142 expect(elem).toBeTruthy();
143 expect(elem.length).toBe(1);
144 });
145
146 it('should update collapsing item', () => {
147 let fgData = {...baseFGData};
148 fgData.children = Array.of(epChild, lkgChild);
149 let laData = {...baseLAData};
150 laData.children = [fgData];
151
152 var renderer = TestUtils.renderIntoDocument(
153 <VLMListView licensingDataList={[laData]} showInUse={true}/>
154 );
155 expect(renderer).toBeTruthy();
156
157 renderer.updateCollapsable(new Event('click'), 'LA1');
158 expect(renderer.state['LA1']).toEqual(true);
159 });
160});