blob: d881985088b5e1b048635f33a1f16919b39237e4 [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 {mapStateToProps} from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverview.js';
18import {overviewEditorHeaders, selectedButton} from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js';
19
20import {LicenseModelOverviewFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
21import { EntitlementPoolStoreFactory as EntitlementPool, EntitlementPoolDataListFactory } from 'test-utils/factories/licenseModel/EntitlementPoolFactories.js';
22import { FeatureGroupStoreFactory as FeatureGroup, FeatureGroupDataListFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js';
23import {LicenseAgreementStoreFactory as LicenseAgreement, LicenseAgreementDataListFactory} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js';
24import { LicenseKeyGroupStoreFactory as LicenseKeyGroup, LicenseKeyGroupDataListFactory} from 'test-utils/factories/licenseModel/LicenseKeyGroupFactories.js';
25
26describe('License Model Overview: ', function () {
27
28 it('should mapper exist', () => {
29 expect(mapStateToProps).toBeTruthy();
30 });
31
ilanapc6a41de2017-11-07 11:54:10 +020032 const VLM1 = LicenseModelOverviewFactory.build({
33 featureGroup: {
34 featureGroupsList: [],
35 },
36 entitlementPool: {
37 entitlementPoolsList: []
38 },
39 licenseKeyGroup: {
40 licenseKeyGroupsList: []
41 }
42 });
AviZi280f8012017-06-09 02:39:56 +030043
44 it('should mapper return vlm overview basic data', () => {
45 const state = {
46 licenseModel: VLM1
47 };
48
49 var props = mapStateToProps(state);
AviZi280f8012017-06-09 02:39:56 +030050 expect(props.isDisplayModal).toEqual(false);
51 expect(props.modalHeader).toEqual(undefined);
52 expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id);
53 expect(props.licensingDataList).toEqual([]);
ilanapc6a41de2017-11-07 11:54:10 +020054 expect(props.orphanDataList).toEqual([]);
AviZi280f8012017-06-09 02:39:56 +030055 expect(props.selectedTab).toEqual(selectedButton.VLM_LIST_VIEW);
56 });
57
58 it('should mapper return overview data for show LA modal', () => {
59 const VLM1 = LicenseModelOverviewFactory.build({
60 licenseAgreement: {
61 licenseAgreementEditor: {
62 data: LicenseAgreement.build()
63 }
ilanapc6a41de2017-11-07 11:54:10 +020064 },
65 featureGroup: {
66 featureGroupsList: [],
67 },
68 entitlementPool: {
69 entitlementPoolsList: []
70 },
71 licenseKeyGroup: {
72 licenseKeyGroupsList: []
AviZi280f8012017-06-09 02:39:56 +030073 }
74 });
75
76 var state = {
77 licenseModel: VLM1
78 };
79
80 var props = mapStateToProps(state);
AviZi280f8012017-06-09 02:39:56 +030081 expect(props.isDisplayModal).toEqual(true);
82 expect(props.modalHeader).toEqual(overviewEditorHeaders.LICENSE_AGREEMENT);
83 expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id);
84 expect(props.licensingDataList).toEqual([]);
85 expect(props.selectedTab).toEqual(selectedButton.VLM_LIST_VIEW);
86 });
87
88 it('should mapper return overview data for show FG modal', () => {
89
90 const VLM1 = LicenseModelOverviewFactory.build({
91 featureGroup: {
92 featureGroupsList: [],
93 featureGroupEditor: {
94 data: FeatureGroup.build()
95 }
96 },
97 entitlementPool: {
98 entitlementPoolsList: []
99 },
100 licenseKeyGroup: {
101 licenseKeyGroupsList: []
102 },
103 licenseModelOverview: {
104 selectedTab: selectedButton.NOT_IN_USE
105 }
106 });
107
108 var state = {
109 licenseModel: VLM1
110 };
111
112 var props = mapStateToProps(state);
AviZi280f8012017-06-09 02:39:56 +0300113 expect(props.isDisplayModal).toEqual(true);
114 expect(props.modalHeader).toEqual(overviewEditorHeaders.FEATURE_GROUP);
115 expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id);
116 expect(props.licensingDataList).toEqual([]);
117 expect(props.selectedTab).toEqual(selectedButton.NOT_IN_USE);
118 });
119
120 it('should mapper return overview data for show EP modal', () => {
talig8e9c0652017-12-20 14:30:43 +0200121 const VLM1 = LicenseModelOverviewFactory.build({
ilanapc6a41de2017-11-07 11:54:10 +0200122 featureGroup: {
123 featureGroupsList: [],
124 },
AviZi280f8012017-06-09 02:39:56 +0300125 entitlementPool: {
ilanapc6a41de2017-11-07 11:54:10 +0200126 entitlementPoolsList: [],
AviZi280f8012017-06-09 02:39:56 +0300127 entitlementPoolEditor: {
128 data: EntitlementPool.build()
129 }
ilanapc6a41de2017-11-07 11:54:10 +0200130 },
131 licenseKeyGroup: {
132 licenseKeyGroupsList: []
AviZi280f8012017-06-09 02:39:56 +0300133 }
134 });
135
136 var state = {
137 licenseModel: VLM1
138 };
139
140 var props = mapStateToProps(state);
AviZi280f8012017-06-09 02:39:56 +0300141 expect(props.isDisplayModal).toEqual(true);
142 expect(props.modalHeader).toEqual(overviewEditorHeaders.ENTITLEMENT_POOL);
143 expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id);
144 expect(props.licensingDataList).toEqual([]);
145 expect(props.selectedTab).toEqual(selectedButton.VLM_LIST_VIEW);
146 });
147
148 it('should mapper return overview data for show LKG modal', () => {
149 const VLM1 = LicenseModelOverviewFactory.build({
150 licenseKeyGroup: {
151 licenseKeyGroupsList: [],
152 licenseKeyGroupsEditor: {
153 data: LicenseKeyGroup.build()
154 }
155 },
156 entitlementPool: {
157 entitlementPoolsList: []
158 },
159 featureGroup: {
160 featureGroupsList: []
161 },
162 licenseModelOverview: {
163 selectedTab: selectedButton.NOT_IN_USE
164 }
165 });
166
167 var state = {
168 licenseModel: VLM1
169 };
170
171 var props = mapStateToProps(state);
AviZi280f8012017-06-09 02:39:56 +0300172 expect(props.isDisplayModal).toEqual(true);
173 expect(props.modalHeader).toEqual(overviewEditorHeaders.LICENSE_KEY_GROUP);
174 expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id);
175 expect(props.licensingDataList).toEqual([]);
176 expect(props.selectedTab).toEqual(selectedButton.NOT_IN_USE);
177 });
178
179 it('should mapper return overview data for Full-hierarchy list view', () => {
180 let EP1 = EntitlementPool.build();
181 let LKG1 = LicenseKeyGroup.build();
182 let FG1 = FeatureGroup.build({
183 entitlementPoolsIds: [EP1.id],
184 licenseKeyGroupsIds: [LKG1.id]
185 });
186 EP1.referencingFeatureGroups = [FG1.id];
187 LKG1.referencingFeatureGroups = [FG1.id];
188 let LA1 = LicenseAgreement.build({
189 featureGroupsIds: [FG1.id]
190 });
191 FG1.referencingLicenseAgreements = LA1.id;
192 let LA2 = LicenseAgreement.build();
193
194 const VLM1 = LicenseModelOverviewFactory.build({
195 licenseAgreement: {
196 licenseAgreementList: [LA1, LA2]
197 },
198 featureGroup: {
199 featureGroupsList: [FG1]
200 },
201 entitlementPool: {
202 entitlementPoolsList: [EP1]
203 },
204 licenseKeyGroup: {
205 licenseKeyGroupsList: [LKG1]
206 },
207 });
208
209 const state = {
210 licenseModel: VLM1
211 };
212
213 const expectedLicensingDataList = [
214 LicenseAgreementDataListFactory.build({
215 ...LA1,
216 children: [
217 FeatureGroupDataListFactory.build({
218 ...FG1,
219 children: [
220 EntitlementPoolDataListFactory.build(EP1),
221 LicenseKeyGroupDataListFactory.build(LKG1)
222 ]
223 })
224 ]
225 }),
226 LicenseAgreementDataListFactory.build(LA2)
227 ];
228
229 var props = mapStateToProps(state);
230
AviZi280f8012017-06-09 02:39:56 +0300231 expect(props.isDisplayModal).toEqual(false);
232 expect(props.modalHeader).toEqual(undefined);
233 expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id);
234 expect(props.licensingDataList).toEqual(expectedLicensingDataList);
235 expect(props.selectedTab).toEqual(selectedButton.VLM_LIST_VIEW);
236 });
237
238 it('should mapper return overview data for list view with 2 levels', () => {
239 let EP1 = EntitlementPool.build();
240 let LKG1 = LicenseKeyGroup.build();
241 let FG1 = FeatureGroup.build();
242 let LA1 = LicenseAgreement.build({
243 featureGroupsIds: [FG1.id]
244 });
245 let LA2 = LicenseAgreement.build();
246 FG1.referencingLicenseAgreements = [LA1.id];
247
248 const VLM1 = LicenseModelOverviewFactory.build({
249 licenseAgreement: {
250 licenseAgreementList: [LA1, LA2]
251 },
252 featureGroup: {
253 featureGroupsList: [FG1]
254 },
255 entitlementPool: {
256 entitlementPoolsList: [EP1]
257 },
258 licenseKeyGroup: {
259 licenseKeyGroupsList: [LKG1]
260 },
261 });
262
263 const state = {
264 licenseModel: VLM1
265 };
266
267 const expectedLicensingDataList = [
268 LicenseAgreementDataListFactory.build({
269 ...LA1,
270 children: [
271 FeatureGroupDataListFactory.build(FG1)
272 ]
273 }),
274 LicenseAgreementDataListFactory.build(LA2)
275 ];
276
277 var props = mapStateToProps(state);
278
AviZi280f8012017-06-09 02:39:56 +0300279 expect(props.isDisplayModal).toEqual(false);
280 expect(props.modalHeader).toEqual(undefined);
281 expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id);
282 expect(props.licensingDataList).toEqual(expectedLicensingDataList);
283 expect(props.selectedTab).toEqual(selectedButton.VLM_LIST_VIEW);
284 });
285
286 it('should mapper return overview data for Full NOT-IN-USE list view', () => {
287 let EP1 = EntitlementPool.build();
288 let LKG1 = LicenseKeyGroup.build();
289 let FG1 = FeatureGroup.build();
290
291 const VLM1 = LicenseModelOverviewFactory.build({
292 licenseAgreement: { licenseAgreementList: [] },
293 featureGroup: {
294 featureGroupsList: [FG1]
295 },
296 entitlementPool: {
297 entitlementPoolsList: [EP1]
298 },
299 licenseKeyGroup: {
300 licenseKeyGroupsList: [LKG1]
301 },
302 licenseModelOverview: {
303 selectedTab: selectedButton.NOT_IN_USE
304 }
305 });
talig8e9c0652017-12-20 14:30:43 +0200306
AviZi280f8012017-06-09 02:39:56 +0300307 const state = {
308 licenseModel: VLM1
309 };
310
311 const expectedLicensingDataList = [
312 FeatureGroupDataListFactory.build(FG1),
313 EntitlementPoolDataListFactory.build(EP1),
314 LicenseKeyGroupDataListFactory.build(LKG1)
315 ];
316
317 var props = mapStateToProps(state);
318
AviZi280f8012017-06-09 02:39:56 +0300319 expect(props.isDisplayModal).toEqual(false);
320 expect(props.modalHeader).toEqual(undefined);
321 expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id);
ilanapc6a41de2017-11-07 11:54:10 +0200322 expect(props.licensingDataList).toEqual([]);
323 expect(props.orphanDataList).toEqual(expectedLicensingDataList);
AviZi280f8012017-06-09 02:39:56 +0300324 expect(props.selectedTab).toEqual(selectedButton.NOT_IN_USE);
325 });
326
327 it('should mapper return overview data for NOT-IN-USE list view (FG with children)', () => {
328 let EP1 = EntitlementPool.build();
329 let LKG1 = LicenseKeyGroup.build();
330 let FG1 = FeatureGroup.build({
331 entitlementPoolsIds: [EP1.id],
332 licenseKeyGroupsIds: [LKG1.id]
333 });
334 EP1.referencingFeatureGroups = [FG1.id];
335 LKG1.referencingFeatureGroups = [FG1.id];
336
337 const VLM1 = LicenseModelOverviewFactory.build({
338 licenseAgreement: { licenseAgreementList: [] },
339 featureGroup: {
340 featureGroupsList: [FG1]
341 },
342 entitlementPool: {
343 entitlementPoolsList: [EP1]
344 },
345 licenseKeyGroup: {
346 licenseKeyGroupsList: [LKG1]
347 },
348 licenseModelOverview: {
349 selectedTab: selectedButton.NOT_IN_USE
350 }
351 });
352
353 const state = {
354 licenseModel: VLM1
355 };
356
357 const expectedLicensingDataList = [
358 FeatureGroupDataListFactory.build({
359 ...FG1,
360 children: [
361 EntitlementPoolDataListFactory.build(EP1),
362 LicenseKeyGroupDataListFactory.build(LKG1)]
363 })
364 ];
365
366 var props = mapStateToProps(state);
367
AviZi280f8012017-06-09 02:39:56 +0300368 expect(props.isDisplayModal).toEqual(false);
369 expect(props.modalHeader).toEqual(undefined);
370 expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id);
ilanapc6a41de2017-11-07 11:54:10 +0200371 expect(props.licensingDataList).toEqual([]);
372 expect(props.orphanDataList).toEqual(expectedLicensingDataList);
AviZi280f8012017-06-09 02:39:56 +0300373 expect(props.selectedTab).toEqual(selectedButton.NOT_IN_USE);
374 });
AviZi280f8012017-06-09 02:39:56 +0300375});