AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 1 | /*! |
| 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 | |
| 17 | import React from 'react'; |
| 18 | import TestUtils from 'react-addons-test-utils'; |
| 19 | import {scryRenderedDOMComponentsWithTestId} from 'test-utils/Util.js'; |
| 20 | import SummaryView from 'sdc-app/onboarding/licenseModel/overview/SummaryView.jsx'; |
| 21 | import LicenseModelOverviewView from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewView.jsx'; |
| 22 | import VLMListView from 'sdc-app/onboarding/licenseModel/overview/VLMListView.jsx'; |
| 23 | import {selectedButton} from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js'; |
| 24 | |
| 25 | import {FeatureGroupListItemFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js'; |
| 26 | import {EntitlementPoolListItemFactory} from 'test-utils/factories/licenseModel/EntitlementPoolFactories.js'; |
| 27 | import {LicenseKeyGroupListItemFactory} from 'test-utils/factories/licenseModel/LicenseKeyGroupFactories.js'; |
| 28 | import {LicenseAgreementListItemFactory} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js'; |
| 29 | |
| 30 | describe('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], |
| 59 | selectedTab: selectedButton.VLM_LIST_VIEW, |
| 60 | onTabSelect: () => {} |
| 61 | }; |
| 62 | var renderer = TestUtils.createRenderer(); |
| 63 | renderer.render( |
| 64 | <LicenseModelOverviewView {...params}/> |
| 65 | ); |
| 66 | let renderedOutput = renderer.getRenderOutput(); |
| 67 | expect(renderedOutput).toBeTruthy(); |
| 68 | }); |
| 69 | |
| 70 | |
| 71 | it('should render empty VLMListView', () => { |
| 72 | const listview = TestUtils.renderIntoDocument( <VLMListView /> ); |
| 73 | expect(listview).toBeTruthy(); |
| 74 | const elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list'); |
| 75 | expect(elem).toBeTruthy(); |
| 76 | expect(elem[0].children.length).toBe(0); |
| 77 | }); |
| 78 | |
| 79 | it('should render VLMListView with licenseAgreement', () => { |
| 80 | const listview = TestUtils.renderIntoDocument( <VLMListView licensingDataList={[baseLAData]}/> ); |
| 81 | expect(listview).toBeTruthy(); |
| 82 | let elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list'); |
| 83 | expect(elem).toBeTruthy(); |
| 84 | expect(elem[0].children.length).toBe(1); |
| 85 | elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-la-item'); |
| 86 | expect(elem).toBeTruthy(); |
| 87 | expect(elem.length).toBe(1); |
| 88 | }); |
| 89 | |
| 90 | it('should render VLMListView with Feature Group', () => { |
| 91 | let laData = {...baseLAData}; |
| 92 | laData.children = [baseFGData]; |
| 93 | const listview = TestUtils.renderIntoDocument( <VLMListView licensingDataList={[laData]}/> ); |
| 94 | expect(listview).toBeTruthy(); |
| 95 | const elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-fg'); |
| 96 | expect(elem).toBeTruthy(); |
| 97 | expect(elem.length).toBe(1); |
| 98 | }); |
| 99 | |
| 100 | it('should render VLMListView with Entitlement Pool', () => { |
| 101 | let fgData = {...baseFGData}; |
| 102 | fgData.children = [epChild]; |
| 103 | let laData = {...baseLAData}; |
| 104 | laData.children = [fgData]; |
| 105 | |
| 106 | const listview = TestUtils.renderIntoDocument( <VLMListView licensingDataList={[laData]} showInUse={true} /> ); |
| 107 | expect(listview).toBeTruthy(); |
| 108 | const elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-ep'); |
| 109 | expect(elem).toBeTruthy(); |
| 110 | expect(elem.length).toBe(1); |
| 111 | }); |
| 112 | |
| 113 | it('should render VLMListView with LicenseKeyGroup', () => { |
| 114 | let fgData = {...baseFGData}; |
| 115 | fgData.children = [lkgChild]; |
| 116 | let laData = {...baseLAData}; |
| 117 | laData.children = [fgData]; |
| 118 | |
| 119 | const listview = TestUtils.renderIntoDocument( <VLMListView licensingDataList={[laData]} showInUse={true} /> ); |
| 120 | expect(listview).toBeTruthy(); |
| 121 | const elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-lkg'); |
| 122 | expect(elem).toBeTruthy(); |
| 123 | expect(elem.length).toBe(1); |
| 124 | }); |
| 125 | |
| 126 | it('should render VLMListView with all items', () => { |
| 127 | let fgData = {...baseFGData}; |
| 128 | fgData.children = Array.of(epChild, lkgChild); |
| 129 | let laData = {...baseLAData}; |
| 130 | laData.children = [fgData]; |
| 131 | |
| 132 | const listview = TestUtils.renderIntoDocument( <VLMListView licensingDataList={[laData]} showInUse={true} /> ); |
| 133 | expect(listview).toBeTruthy(); |
| 134 | let elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-fg'); |
| 135 | expect(elem).toBeTruthy(); |
| 136 | expect(elem.length).toBe(1); |
| 137 | elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-lkg'); |
| 138 | expect(elem).toBeTruthy(); |
| 139 | expect(elem.length).toBe(1); |
| 140 | elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-ep'); |
| 141 | expect(elem).toBeTruthy(); |
| 142 | expect(elem.length).toBe(1); |
| 143 | }); |
| 144 | |
| 145 | it('should update collapsing item', () => { |
| 146 | let fgData = {...baseFGData}; |
| 147 | fgData.children = Array.of(epChild, lkgChild); |
| 148 | let laData = {...baseLAData}; |
| 149 | laData.children = [fgData]; |
| 150 | |
| 151 | var renderer = TestUtils.renderIntoDocument( |
| 152 | <VLMListView licensingDataList={[laData]} showInUse={true}/> |
| 153 | ); |
| 154 | expect(renderer).toBeTruthy(); |
| 155 | |
| 156 | renderer.updateCollapsable(new Event('click'), 'LA1'); |
| 157 | expect(renderer.state['LA1']).toEqual(true); |
| 158 | }); |
| 159 | }); |