svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2016-2017 European Support Limited |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 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 |
svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 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. |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | import React from 'react'; |
svishnev | aa2eece | 2018-01-18 17:52:06 +0200 | [diff] [blame] | 18 | |
| 19 | import TestUtils from 'react-addons-test-utils'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 20 | import {scryRenderedDOMComponentsWithTestId} from 'test-utils/Util.js'; |
| 21 | import SummaryView from 'sdc-app/onboarding/licenseModel/overview/SummaryView.jsx'; |
| 22 | import LicenseModelOverviewView from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewView.jsx'; |
| 23 | import VLMListView from 'sdc-app/onboarding/licenseModel/overview/VLMListView.jsx'; |
| 24 | import {selectedButton} from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js'; |
| 25 | |
| 26 | import {FeatureGroupListItemFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js'; |
| 27 | import {EntitlementPoolListItemFactory} from 'test-utils/factories/licenseModel/EntitlementPoolFactories.js'; |
| 28 | import {LicenseKeyGroupListItemFactory} from 'test-utils/factories/licenseModel/LicenseKeyGroupFactories.js'; |
| 29 | import {LicenseAgreementListItemFactory} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js'; |
| 30 | |
| 31 | describe('License Model Overview - View: ', function () { |
| 32 | |
| 33 | const lkgChild = LicenseKeyGroupListItemFactory.build(); |
| 34 | |
| 35 | const epChild = EntitlementPoolListItemFactory.build(); |
| 36 | |
| 37 | const baseFGData = FeatureGroupListItemFactory.build({isCollapsed: false}); |
| 38 | const baseLAData = LicenseAgreementListItemFactory.build({isCollapse: false}); |
| 39 | |
| 40 | it('should render SummaryView', () => { |
svishnev | aa2eece | 2018-01-18 17:52:06 +0200 | [diff] [blame] | 41 | var renderer = TestUtils.createRenderer(); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 42 | renderer.render( |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 43 | <SummaryView isReadOnly={false} /> |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 44 | ); |
| 45 | let renderedOutput = renderer.getRenderOutput(); |
| 46 | expect(renderedOutput).toBeTruthy(); |
| 47 | }); |
| 48 | |
| 49 | it('should render LicenseModelOverviewView', () => { |
| 50 | let fgData = {...baseFGData}; |
| 51 | fgData.children = Array.of(epChild, lkgChild); |
| 52 | let laData = {...baseLAData}; |
| 53 | laData.children = [fgData]; |
| 54 | |
| 55 | const params = { |
| 56 | licenseModelId: 'VLM1', |
| 57 | isDisplayModal: false, |
| 58 | modalHeader: undefined, |
| 59 | licensingDataList: [laData], |
ilanap | c6a41de | 2017-11-07 11:54:10 +0200 | [diff] [blame] | 60 | orphanDataList: [], |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 61 | selectedTab: selectedButton.VLM_LIST_VIEW, |
| 62 | onTabSelect: () => {} |
| 63 | }; |
svishnev | aa2eece | 2018-01-18 17:52:06 +0200 | [diff] [blame] | 64 | var renderer = TestUtils.createRenderer(); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 65 | renderer.render( |
| 66 | <LicenseModelOverviewView {...params}/> |
| 67 | ); |
| 68 | let renderedOutput = renderer.getRenderOutput(); |
| 69 | expect(renderedOutput).toBeTruthy(); |
| 70 | }); |
| 71 | |
| 72 | |
| 73 | it('should render empty VLMListView', () => { |
| 74 | const listview = TestUtils.renderIntoDocument( <VLMListView /> ); |
| 75 | expect(listview).toBeTruthy(); |
| 76 | const elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list'); |
| 77 | expect(elem).toBeTruthy(); |
| 78 | expect(elem[0].children.length).toBe(0); |
| 79 | }); |
| 80 | |
| 81 | it('should render VLMListView with licenseAgreement', () => { |
| 82 | const listview = TestUtils.renderIntoDocument( <VLMListView licensingDataList={[baseLAData]}/> ); |
| 83 | expect(listview).toBeTruthy(); |
| 84 | let elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list'); |
| 85 | expect(elem).toBeTruthy(); |
| 86 | expect(elem[0].children.length).toBe(1); |
| 87 | elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-la-item'); |
| 88 | expect(elem).toBeTruthy(); |
| 89 | expect(elem.length).toBe(1); |
| 90 | }); |
| 91 | |
| 92 | it('should render VLMListView with Feature Group', () => { |
| 93 | let laData = {...baseLAData}; |
| 94 | laData.children = [baseFGData]; |
| 95 | const listview = TestUtils.renderIntoDocument( <VLMListView licensingDataList={[laData]}/> ); |
| 96 | expect(listview).toBeTruthy(); |
| 97 | const elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-fg'); |
| 98 | expect(elem).toBeTruthy(); |
| 99 | expect(elem.length).toBe(1); |
| 100 | }); |
| 101 | |
| 102 | it('should render VLMListView with Entitlement Pool', () => { |
| 103 | let fgData = {...baseFGData}; |
| 104 | fgData.children = [epChild]; |
| 105 | let laData = {...baseLAData}; |
| 106 | laData.children = [fgData]; |
| 107 | |
| 108 | const listview = TestUtils.renderIntoDocument( <VLMListView licensingDataList={[laData]} showInUse={true} /> ); |
| 109 | expect(listview).toBeTruthy(); |
| 110 | const elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-ep'); |
| 111 | expect(elem).toBeTruthy(); |
| 112 | expect(elem.length).toBe(1); |
| 113 | }); |
| 114 | |
| 115 | it('should render VLMListView with LicenseKeyGroup', () => { |
| 116 | let fgData = {...baseFGData}; |
| 117 | fgData.children = [lkgChild]; |
| 118 | let laData = {...baseLAData}; |
| 119 | laData.children = [fgData]; |
| 120 | |
| 121 | const listview = TestUtils.renderIntoDocument( <VLMListView licensingDataList={[laData]} showInUse={true} /> ); |
| 122 | expect(listview).toBeTruthy(); |
| 123 | const elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-lkg'); |
| 124 | expect(elem).toBeTruthy(); |
| 125 | expect(elem.length).toBe(1); |
| 126 | }); |
| 127 | |
| 128 | it('should render VLMListView with all items', () => { |
| 129 | let fgData = {...baseFGData}; |
| 130 | fgData.children = Array.of(epChild, lkgChild); |
| 131 | let laData = {...baseLAData}; |
| 132 | laData.children = [fgData]; |
| 133 | |
| 134 | const listview = TestUtils.renderIntoDocument( <VLMListView licensingDataList={[laData]} showInUse={true} /> ); |
| 135 | expect(listview).toBeTruthy(); |
| 136 | let elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-fg'); |
| 137 | expect(elem).toBeTruthy(); |
| 138 | expect(elem.length).toBe(1); |
| 139 | elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-lkg'); |
| 140 | expect(elem).toBeTruthy(); |
| 141 | expect(elem.length).toBe(1); |
| 142 | elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-ep'); |
| 143 | expect(elem).toBeTruthy(); |
| 144 | expect(elem.length).toBe(1); |
| 145 | }); |
| 146 | |
| 147 | it('should update collapsing item', () => { |
| 148 | let fgData = {...baseFGData}; |
| 149 | fgData.children = Array.of(epChild, lkgChild); |
| 150 | let laData = {...baseLAData}; |
| 151 | laData.children = [fgData]; |
| 152 | |
| 153 | var renderer = TestUtils.renderIntoDocument( |
| 154 | <VLMListView licensingDataList={[laData]} showInUse={true}/> |
| 155 | ); |
| 156 | expect(renderer).toBeTruthy(); |
| 157 | |
| 158 | renderer.updateCollapsable(new Event('click'), 'LA1'); |
| 159 | expect(renderer.state['LA1']).toEqual(true); |
| 160 | }); |
| 161 | }); |