From 280f8015d06af1f41a3ef12e8300801c7a5e0d54 Mon Sep 17 00:00:00 2001 From: AviZi Date: Fri, 9 Jun 2017 02:39:56 +0300 Subject: [SDC-29] Amdocs OnBoard 1707 initial commit. Change-Id: Ie4d12a3f574008b792899b368a0902a8b46b5370 Signed-off-by: AviZi --- .../nfvo-components/SubmitErrorResponse.test.js | 33 + .../__snapshots__/storyshots.test.js.snap | 686 +++++++++++++++++++++ .../activity-log/ActivityLog.test.js | 89 +++ .../nfvo-components/editor/TabulatedEditor.test.js | 52 ++ .../input/dualListBox/dualListbox.test.js | 85 +-- .../nfvo-components/input/validation/input.test.js | 141 +++++ .../nfvo-components/listEditor/listEditor.test.js | 60 +- .../test/nfvo-components/modal/globalModal.test.js | 92 +++ .../notifications/notificationsModal.test.js | 144 ----- .../VersionController/versionController.test.js | 145 ++++- .../versionControllerUtils.test.js | 132 ++-- .../test/nfvo-components/storyshots.test.js | 2 + 12 files changed, 1342 insertions(+), 319 deletions(-) create mode 100644 openecomp-ui/test/nfvo-components/SubmitErrorResponse.test.js create mode 100644 openecomp-ui/test/nfvo-components/__snapshots__/storyshots.test.js.snap create mode 100644 openecomp-ui/test/nfvo-components/activity-log/ActivityLog.test.js create mode 100644 openecomp-ui/test/nfvo-components/editor/TabulatedEditor.test.js create mode 100644 openecomp-ui/test/nfvo-components/input/validation/input.test.js create mode 100644 openecomp-ui/test/nfvo-components/modal/globalModal.test.js delete mode 100644 openecomp-ui/test/nfvo-components/notifications/notificationsModal.test.js create mode 100644 openecomp-ui/test/nfvo-components/storyshots.test.js (limited to 'openecomp-ui/test/nfvo-components') diff --git a/openecomp-ui/test/nfvo-components/SubmitErrorResponse.test.js b/openecomp-ui/test/nfvo-components/SubmitErrorResponse.test.js new file mode 100644 index 0000000000..7231fe4abc --- /dev/null +++ b/openecomp-ui/test/nfvo-components/SubmitErrorResponse.test.js @@ -0,0 +1,33 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + + +import React from 'react'; +import TestUtils from 'react-addons-test-utils'; + +import SubmitErrorResponse from 'nfvo-components/SubmitErrorResponse.jsx'; +import {SubmitErrorMessageFactory} from 'test-utils/factories/SubnitErrorMessageFactorie.js'; + +describe('SubmitErrorResponse test: ', function () { + it('basic render test', () => { + let props = { + validationResponse: SubmitErrorMessageFactory.build() + }; + + let view = TestUtils.renderIntoDocument(); + expect(view).toBeTruthy(); + }); +}); diff --git a/openecomp-ui/test/nfvo-components/__snapshots__/storyshots.test.js.snap b/openecomp-ui/test/nfvo-components/__snapshots__/storyshots.test.js.snap new file mode 100644 index 0000000000..f7df9763da --- /dev/null +++ b/openecomp-ui/test/nfvo-components/__snapshots__/storyshots.test.js.snap @@ -0,0 +1,686 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Storyshots ListEditor regular 1`] = ` +
+
+
+ List Editor +
+
+
+
+
+
+
+
+
+ Lorum Ipsum +
+
+
+
+ Lorum Ipsum +
+
+
+
+
+
+
+
+ Lorum Ipsum +
+
+
+
+ Lorum Ipsum +
+
+
+
+
+
+
+`; + +exports[`Storyshots ListEditor two columns 1`] = ` +
+
+
+ List Editor +
+
+
+
+
+
+
+
+
+ Lorum Ipsum +
+
+
+
+ Lorum Ipsum +
+
+
+
+
+
+
+
+ Lorum Ipsum +
+
+
+
+ Lorum Ipsum +
+
+
+
+
+
+
+`; + +exports[`Storyshots ListEditor with add 1`] = ` +
+
+
+ List Editor +
+
+
+ + + Add + +
+
+
+
+
+
+
+
+
+ Lorum Ipsum +
+
+
+
+ Lorum Ipsum +
+
+
+
+
+
+
+
+ Lorum Ipsum +
+
+
+
+ Lorum Ipsum +
+
+
+
+
+
+
+`; + +exports[`Storyshots ListEditor with delete 1`] = ` +
+
+
+ List Editor +
+
+
+ + + Add + +
+
+
+
+
+
+
+
+
+ Lorum Ipsum +
+
+
+
+ Lorum Ipsum +
+
+
+
+
+ + + + +
+
+
+
+
+
+
+ Lorum Ipsum +
+
+
+
+ Lorum Ipsum +
+
+
+
+
+ + + + +
+
+
+
+
+
+`; + +exports[`Storyshots ListEditor with edit 1`] = ` +
+
+
+ List Editor +
+
+
+ + + Add + +
+
+
+
+
+
+
+
+
+ Lorum Ipsum +
+
+
+
+ Lorum Ipsum +
+
+
+
+
+ + + + +
+
+
+
+
+
+
+ Lorum Ipsum +
+
+
+
+ Lorum Ipsum +
+
+
+
+
+ + + + +
+
+
+
+
+
+`; + +exports[`Storyshots ListEditor with edit and delete 1`] = ` +
+
+
+ List Editor +
+
+
+ + + Add + +
+
+
+
+
+
+
+
+
+ Lorum Ipsum +
+
+
+
+ Lorum Ipsum +
+
+
+
+
+ + + + +
+
+ + + + +
+
+
+
+
+
+
+ Lorum Ipsum +
+
+
+
+ Lorum Ipsum +
+
+
+
+
+ + + + +
+
+ + + + +
+
+
+
+
+
+`; + +exports[`Storyshots SVGIcon icon 1`] = ` +
+ + + + +
+`; + +exports[`Storyshots SVGIcon icon with label 1`] = ` +
+ + + + + locked + +
+`; + +exports[`Storyshots SVGIcon locked clickable 1`] = ` +
+ + + + +
+`; diff --git a/openecomp-ui/test/nfvo-components/activity-log/ActivityLog.test.js b/openecomp-ui/test/nfvo-components/activity-log/ActivityLog.test.js new file mode 100644 index 0000000000..2f377a3539 --- /dev/null +++ b/openecomp-ui/test/nfvo-components/activity-log/ActivityLog.test.js @@ -0,0 +1,89 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +import React from 'react'; +import {mount} from 'enzyme'; +import {cloneAndSet} from 'test-utils/Util.js'; +import ActivityLogView, {ActivityListItem} from 'nfvo-components/activity-log/ActivityLogView.jsx'; +import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx'; +import ActivityLogActionHelper from 'nfvo-components/activity-log/ActivityLogActionHelper.js'; +import {mapStateToProps} from 'nfvo-components/activity-log/ActivityLog.js'; +import {storeCreator} from 'sdc-app/AppStore.js'; +import mockRest from 'test-utils/MockRest.js'; +import {ActivityLogStoreFactory} from 'test-utils/factories/activity-log/ActivityLogFactories.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; + +describe('Activity Log Module Tests', function () { + const LICENSE_MODEL_ID = '555'; + const version = VersionControllerUtilsFactory.build().version; + + it('mapStateToProps mapper exists', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it('Loads Activity Log and renders into jsx', () => { + const store = storeCreator(); + const dispatch = store.dispatch; + let ActivityLogList = ActivityLogStoreFactory.buildList(1); + const expectedStore = cloneAndSet(store.getState(), 'licenseModel.activityLog', ActivityLogList); + + mockRest.addHandler('fetch', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/activity-logs/${LICENSE_MODEL_ID}/versions/${version.id}`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: ActivityLogList}; + }); + + return ActivityLogActionHelper.fetchActivityLog(dispatch, {itemId: LICENSE_MODEL_ID, versionId: version.id}).then(() => { + const state = store.getState(); + expect(state).toEqual(expectedStore); + const props = mapStateToProps(state); + expect(props.activities).toEqual(ActivityLogList); + const wrapper = mount(); + expect(wrapper).toBeTruthy(); + }); + }); + + it('Tests Activity Log filter and sorting abilities', () => { + const firstDate = new Date(); + const secondDate = new Date(); + secondDate.setDate(firstDate.getDate() - 1); + + const firstTimestamp = firstDate.getTime(); + const secondTimestamp = secondDate.getTime(); + + let firstActivity = ActivityLogStoreFactory.build({user: 'first', timestamp: firstTimestamp}); + let secondActivity = ActivityLogStoreFactory.build({user: 'second', timestamp: secondTimestamp, status: {success: false, message: 'error'}}); + let props = mapStateToProps({licenseModel: {activityLog: [firstActivity, secondActivity]}}); + const wrapper = mount(); + expect(wrapper.find(ActivityListItem).length).toEqual(3); // Includes Header component + + const firstInstance = wrapper.find(ActivityListItem).at(1); + const firstInstanceProps = firstInstance.props(); + expect(firstInstanceProps.activity.timestamp).toEqual(secondTimestamp); // Default sorting is descending + + const header = wrapper.find(ActivityListItem).at(0); + header.props().onSort(); + const newFirstInstance = wrapper.find(ActivityListItem).at(1); + const newFirstInstanceProps = newFirstInstance.props(); + expect(newFirstInstanceProps.activity.timestamp).toEqual(firstTimestamp); + + const listEditor = wrapper.find(ListEditorView); + listEditor.props().onFilter('second'); + expect(wrapper.find(ActivityListItem).length).toEqual(2); + expect(wrapper.find(ActivityListItem).at(1).props().activity.user).toEqual('second'); + }); +}); diff --git a/openecomp-ui/test/nfvo-components/editor/TabulatedEditor.test.js b/openecomp-ui/test/nfvo-components/editor/TabulatedEditor.test.js new file mode 100644 index 0000000000..e61261e09a --- /dev/null +++ b/openecomp-ui/test/nfvo-components/editor/TabulatedEditor.test.js @@ -0,0 +1,52 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + + +import React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import TabulatedEditor from 'nfvo-components/editor/TabulatedEditor.jsx'; + +describe('Tabulated Editor test: ', function () { + + it('basic view test', () => { + let renderer = TestUtils.createRenderer(); + renderer.render( + + ); + let renderedOutput = renderer.getRenderOutput(); + expect(renderedOutput).toBeTruthy(); + + }); + + it('handle func test', () => { + let props = { + navigationBarProps: { + groups: [], + onNavigationItemClick: ()=>{} + }, + versionControllerProps: { + isCheckedOut: false, + version: {id: '0.1', label: '0.1'}, + viewableVersions: [{id: '0.1', label: '0.1'}], + onSubmit: ()=>{}, + onRevert: ()=>{} + } + }; + const view = TestUtils.renderIntoDocument(); + expect(view).toBeTruthy(); + }); + +}); diff --git a/openecomp-ui/test/nfvo-components/input/dualListBox/dualListbox.test.js b/openecomp-ui/test/nfvo-components/input/dualListBox/dualListbox.test.js index eaa06eedf4..c578178d35 100644 --- a/openecomp-ui/test/nfvo-components/input/dualListBox/dualListbox.test.js +++ b/openecomp-ui/test/nfvo-components/input/dualListBox/dualListbox.test.js @@ -1,24 +1,19 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. */ -import expect from 'expect'; import React from 'react'; import TestUtils from 'react-addons-test-utils'; import DualListboxView from 'nfvo-components/input/dualListbox/DualListboxView.jsx'; @@ -32,42 +27,62 @@ describe('dualListBox Module Tests', function () { var renderer = TestUtils.createRenderer(); renderer.render({}}/>); var renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); it('should render with available list and 4 control buttons', () => { var view = TestUtils.renderIntoDocument({}}/>); - expect(view).toExist(); + expect(view).toBeTruthy(); var results = TestUtils.scryRenderedDOMComponentsWithClass(view, 'dual-list-option'); expect(results.length).toBe(4); }); it('should add item to selected list', done => { - const newItemValue = 'new item'; - let onChange = (value)=> { - expect(value).toEqual(newItemValue); + const onChange = (values)=> { + expect(values).toEqual([ITEMS[2].id, ITEMS[0].id]); done(); }; - var view = new DualListboxView({availableList:ITEMS, onChange, selectedValuesList:[]}); - expect(view).toExist(); - view.refs = { - availableValues: {getValue(){return newItemValue;}} - }; - view.addToSelectedList(); + const document = TestUtils.renderIntoDocument( + ); + + const result = TestUtils.scryRenderedDOMComponentsWithTag(document, 'select'); + const options = TestUtils.scryRenderedDOMComponentsWithTag(document, 'option'); + const listBox = TestUtils.findRenderedComponentWithType(document, DualListboxView); + expect(result).toBeTruthy(); + expect(options).toBeTruthy(); + expect(listBox).toBeTruthy(); + + TestUtils.Simulate.change(result[0], {target: {selectedOptions: [options[0]]}}); + expect(listBox.state.selectedValues).toEqual([ITEMS[0].id]); + + listBox.addToSelectedList(); }); it('should remove item from selected list', done => { - const selectedValuesList = ['a','b']; - let onChange = (value)=> { - expect(value).toEqual(selectedValuesList[1]); + const onChange = (values)=> { + expect(values).toEqual([ITEMS[0].id]); done(); }; - var view = new DualListboxView({availableList:ITEMS, onChange, selectedValuesList}); - expect(view).toExist(); - view.refs = { - selectedValues: {getValue(){return ['a'];}} - }; - view.removeFromSelectedList(); + const document = TestUtils.renderIntoDocument( + ); + + const result = TestUtils.scryRenderedDOMComponentsWithTag(document, 'select'); + const options = TestUtils.scryRenderedDOMComponentsWithTag(document, 'option'); + const listBox = TestUtils.findRenderedComponentWithType(document, DualListboxView); + expect(result).toBeTruthy(); + expect(options).toBeTruthy(); + expect(listBox).toBeTruthy(); + + TestUtils.Simulate.change(result[1], {target: {selectedOptions: [options[2]]}}); + expect(listBox.state.selectedValues).toEqual([ITEMS[1].id]); + + listBox.removeFromSelectedList(); }); it('should add all items to selected list', done => { @@ -76,7 +91,7 @@ describe('dualListBox Module Tests', function () { done(); }; var view = new DualListboxView({availableList:ITEMS, onChange, selectedValuesList:[]}); - expect(view).toExist(); + expect(view).toBeTruthy(); view.addAllToSelectedList(); }); @@ -86,7 +101,7 @@ describe('dualListBox Module Tests', function () { done(); }; var view = new DualListboxView({availableList:ITEMS, onChange, selectedValuesList:[]}); - expect(view).toExist(); + expect(view).toBeTruthy(); view.removeAllFromSelectedList(); }); diff --git a/openecomp-ui/test/nfvo-components/input/validation/input.test.js b/openecomp-ui/test/nfvo-components/input/validation/input.test.js new file mode 100644 index 0000000000..7743483603 --- /dev/null +++ b/openecomp-ui/test/nfvo-components/input/validation/input.test.js @@ -0,0 +1,141 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +import React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import {scryRenderedDOMComponentsWithTestId} from 'test-utils/Util.js'; +import Input from 'nfvo-components/input/validation/Input.jsx'; +import Overlay from 'react-bootstrap/lib/Overlay.js'; + +describe('Input', function () { + it('should render with type text', () => { + let renderedOutput = TestUtils.renderIntoDocument(); + const elem = scryRenderedDOMComponentsWithTestId(renderedOutput,'mytest'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + expect(elem[0].type).toBe('text'); + }); + + it('should render with type textarea', () => { + let renderedOutput = TestUtils.renderIntoDocument(); + const elem = scryRenderedDOMComponentsWithTestId(renderedOutput,'mytest'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + expect(elem[0].tagName.toLowerCase()).toBe('textarea'); + }); + + it('should render with type radio', () => { + let renderedOutput = TestUtils.renderIntoDocument(); + const elem = scryRenderedDOMComponentsWithTestId(renderedOutput,'mytest'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + expect(elem[0].type).toBe('radio'); + }); + + it('should render with type select', () => { + let renderedOutput = TestUtils.renderIntoDocument(); + const elem = scryRenderedDOMComponentsWithTestId(renderedOutput,'mytest'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + expect(elem[0].tagName.toLowerCase()).toBe('select'); + }); + + it('should render with type number', () => { + let renderedOutput = TestUtils.renderIntoDocument(); + const elem = scryRenderedDOMComponentsWithTestId(renderedOutput,'mytest'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + expect(elem[0].tagName.toLowerCase()).toBe('input'); + expect(elem[0].type).toBe('number'); + }); + + it('should render with type checkbox', () => { + let renderedOutput = TestUtils.renderIntoDocument(); + const elem = scryRenderedDOMComponentsWithTestId(renderedOutput,'mytest'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + expect(elem[0].tagName.toLowerCase()).toBe('input'); + expect(elem[0].type).toBe('checkbox'); + }); + + it('should render error overlay when invalid', () => { + let renderedOutput = TestUtils.renderIntoDocument(); + const elem = TestUtils.findRenderedComponentWithType(renderedOutput,Overlay); + expect(elem).toBeTruthy(); + expect(elem.props.show).toBe(true); + }); + + it('should not render error overlay when valid', () => { + let renderedOutput = TestUtils.renderIntoDocument(); + const elem = TestUtils.findRenderedComponentWithType(renderedOutput,Overlay); + expect(elem).toBeTruthy(); + expect(elem.props.show).toBe(false); + }); + + /*it('should return the value of a select', () => { + + }); + + it('should return the value of a checkbox', () => { + + }); + + it('should return the value of a radio', () => { + + }); + + it('should return the value of a text', () => { + + }); + + it('should return the value of a textarea', () => { + + });*/ + + /*it('should render and work as a group', () => { + let MockComp = React.createClass({ + render: function() { + return (
+ +
); + } + }); + let renderedOutput = TestUtils.renderIntoDocument(); + const radio1 = scryRenderedDOMComponentsWithTestId(renderedOutput,'mytest'); + expect(radio1).toBeTruthy(); + expect(radio1.length).toBe(1); + expect(radio1[0].type).toBe('radio'); + expect(radio1[0].value).toBe('0'); + const radio2 = scryRenderedDOMComponentsWithTestId(renderedOutput,'mytest1'); + expect(radio2).toBeTruthy(); + expect(radio2.length).toBe(1); + expect(radio2[0].type).toBe('radio'); + expect(radio2[0].value).toBe('1'); + TestUtils.Simulate.click( + radio2[0] + ); + TestUtils.Simulate.click( + radio1[0] + ); + console.log('radio1: ' + radio1[0].checked); + console.log('radio2: ' + radio2[0].checked); + expect(radio2[0].checked).toBe(false); + expect(radio1[0].checked).toBe(true); + + + });*/ + +}); diff --git a/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js b/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js index a3b098f611..c1f823c3fc 100644 --- a/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js +++ b/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js @@ -1,25 +1,21 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. */ -import expect from 'expect'; import React from 'react'; +import {mount} from 'enzyme'; import TestUtils from 'react-addons-test-utils'; import ListEditorView from 'src/nfvo-components/listEditor/ListEditorView.jsx'; import ListEditorItemView from 'src/nfvo-components/listEditor/ListEditorItemView.jsx'; @@ -28,11 +24,11 @@ describe('listEditor Module Tests', function () { it('list editor view should exist', () => { - expect(ListEditorView).toExist(); + expect(ListEditorView).toBeTruthy(); }); it('list editor item view should exist', () => { - expect(ListEditorItemView).toExist(); + expect(ListEditorItemView).toBeTruthy(); }); it('should render list and list item and call onEdit', done => { @@ -43,22 +39,18 @@ describe('listEditor Module Tests', function () { ); - expect(itemView).toExist(); - let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'fa-sliders'); + expect(itemView).toBeTruthy(); + let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'sliders'); TestUtils.Simulate.click(sliderIcon); }); - it('should render list and list item and call onFilter', done => { - let itemView = TestUtils.renderIntoDocument( - {done();}}> - -
-
-
+ it('should render list and list item and call onFilter', () => { + let itemView = mount( + {}} children={[()]} /> ); - expect(itemView).toExist(); - let filterInput = TestUtils.findRenderedDOMComponentWithTag(itemView, 'input'); - TestUtils.Simulate.change(filterInput); + expect(itemView).toBeTruthy(); + let inputComponent = itemView.find('ExpandableInput'); + expect(inputComponent.length).toBe(1); }); it('should render READONLY list item and not call onEdit', done => { @@ -67,8 +59,8 @@ describe('listEditor Module Tests', function () {
); - expect(itemView).toExist(); - let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'fa-sliders'); + expect(itemView).toBeTruthy(); + let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'sliders'); TestUtils.Simulate.click(sliderIcon); }); @@ -78,8 +70,8 @@ describe('listEditor Module Tests', function () {
); - expect(itemView).toExist(); - let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'fa-trash-o'); + expect(itemView).toBeTruthy(); + let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'trash-o'); TestUtils.Simulate.click(sliderIcon); }); @@ -89,8 +81,8 @@ describe('listEditor Module Tests', function () {
); - expect(itemView).toExist(); - let sliderIcon = TestUtils.scryRenderedDOMComponentsWithClass(itemView, 'fa-trash-o'); - expect(sliderIcon).toEqual(0); + expect(itemView).toBeTruthy(); + let trashIcon = TestUtils.scryRenderedDOMComponentsWithClass(itemView, 'fa-trash-o'); + expect(trashIcon).toEqual([]); }); }); diff --git a/openecomp-ui/test/nfvo-components/modal/globalModal.test.js b/openecomp-ui/test/nfvo-components/modal/globalModal.test.js new file mode 100644 index 0000000000..efe43b6c37 --- /dev/null +++ b/openecomp-ui/test/nfvo-components/modal/globalModal.test.js @@ -0,0 +1,92 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +import GlobalModal, {GlobalModalView, mapStateToProps} from 'src/nfvo-components/modal/GlobalModal.js'; +import React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import store from 'sdc-app/AppStore.js'; +import {actionTypes, typeEnum} from 'src/nfvo-components/modal/GlobalModalConstants.js'; + +const title = 'TITLE'; +const msg = 'message'; + +describe('Global Modal tests: ', function () { + it (' mapStateToProps exists', function () { + expect(mapStateToProps).toBeTruthy(); + }); + + it ('mapStateToProps should return show as true', () => { + let state = { + modal: { + type: '' + } + }; + let props = mapStateToProps(state); + expect(props.show).toEqual(true); + }); + + it('modal should show with default values', () => { + store.dispatch({ + type: actionTypes.GLOBAL_MODAL_SHOW, + data: { + title, + msg + } + }); + const modal = store.getState().modal; + expect(modal).toBeTruthy(); + expect(modal.title).toBe(title); + expect(modal.msg).toBe(msg); + }); + + it('global modal should show with type success with connected component', () => { + store.dispatch({type: actionTypes.GLOBAL_MODAL_SHOW, data: {title, msg}}); + + expect(store.getState().modal).toBeTruthy(); + + let renderer = TestUtils.createRenderer(); + renderer.render(); + let renderedOutput = renderer.getRenderOutput(); + expect(renderedOutput).toBeTruthy(); + + }); + + + it('global modal should show with type success with connected component and closed after', () => { + store.dispatch({type: actionTypes.GLOBAL_MODAL_SHOW, data: {title, msg}}); + + expect(store.getState().modal).toBeTruthy(); + + let renderer = TestUtils.createRenderer(); + renderer.render(); + let renderedOutput = renderer.getRenderOutput(); + expect(renderedOutput).toBeTruthy(); + + store.dispatch({type: actionTypes.GLOBAL_MODAL_CLOSE}); + expect(store.getState().modal).toBe(null); + }); + + + it('checking component default render', ()=> { + expect(window.document).toBeTruthy(); + let globalModalView = TestUtils.renderIntoDocument( + {}} /> + ); + expect(globalModalView).toBeTruthy(); + }); + +}); + diff --git a/openecomp-ui/test/nfvo-components/notifications/notificationsModal.test.js b/openecomp-ui/test/nfvo-components/notifications/notificationsModal.test.js deleted file mode 100644 index f84d38246d..0000000000 --- a/openecomp-ui/test/nfvo-components/notifications/notificationsModal.test.js +++ /dev/null @@ -1,144 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -import expect from 'expect'; -import React from 'react'; -import TestUtils from 'react-addons-test-utils'; -import store from 'sdc-app/AppStore.js'; -import ConnectedNotificationModal, {NotificationModal} from 'nfvo-components/notifications/NotificationModal.jsx'; -import NotificationConstants from 'nfvo-components/notifications/NotificationConstants.js'; - -const title = 'test title'; -const msg = 'test msg'; - -describe('Notification Modal Mapper and View Class: ', function () { - - it('notification should show with type error', done => { - store.dispatch({type: NotificationConstants.NOTIFY_ERROR, data: {title, msg}}); - setTimeout(()=> { - expect(store.getState().notification).toExist(); - expect(store.getState().notification.type).toBe('error'); - done(); - }, 0); - }); - - it('notification should show with type default', done => { - store.dispatch({type: NotificationConstants.NOTIFY_INFO, data: {title, msg}}); - setTimeout(()=> { - expect(store.getState().notification).toExist(); - expect(store.getState().notification.type).toBe('default'); - done(); - }, 0); - }); - - it('notification should show with type warning', done => { - store.dispatch({type: NotificationConstants.NOTIFY_WARNING, data: {title, msg}}); - setTimeout(()=> { - expect(store.getState().notification).toExist(); - expect(store.getState().notification.type).toBe('warning'); - done(); - }, 0); - }); - - it('notification should show with type success', done => { - store.dispatch({type: NotificationConstants.NOTIFY_SUCCESS, data: {title, msg}}); - setTimeout(()=> { - expect(store.getState().notification).toExist(); - expect(store.getState().notification.type).toBe('success'); - done(); - }, 0); - }); - - it('notification should show with type success with connected component', done => { - store.dispatch({type: NotificationConstants.NOTIFY_SUCCESS, data: {title, msg}}); - setTimeout(()=> { - expect(store.getState().notification).toExist(); - expect(store.getState().notification.type).toBe('success'); - let renderer = TestUtils.createRenderer(); - renderer.render(); - let renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); - done(); - }, 0); - }); - - it('notification should hide with connected component', done => { - setTimeout(()=> { - expect(store.getState().notification).toNotExist(); - let renderer = TestUtils.createRenderer(); - renderer.render(); - let renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); - done(); - }, 0); - store.dispatch({type: NotificationConstants.NOTIFY_CLOSE}); - }); - - it('notification should hide', done => { - store.dispatch({type: NotificationConstants.NOTIFY_CLOSE}); - setTimeout(()=> { - expect(store.getState().notification).toNotExist(); - done(); - }, 0); - }); - - it('NotificationModal should not render', ()=> { - let renderer = TestUtils.createRenderer(); - renderer.render(); - let renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); - }); - - it('NotificationModal basic default render', ()=> { - expect(window.document).toExist(); - let document = TestUtils.renderIntoDocument( - {}}/> - ); - var result = TestUtils.findAllInRenderedTree(document, element => element.props.className === 'notification-modal primary'); - expect(result.length).toBeGreaterThan(0); - }); - - it('NotificationModal basic error render', ()=> { - expect(window.document).toExist(); - let document = TestUtils.renderIntoDocument( - {}}/> - ); - var result = TestUtils.findAllInRenderedTree(document, element => element.props.className === 'notification-modal danger'); - expect(result.length).toBeGreaterThan(0); - }); - - it('NotificationModal basic warning render', ()=> { - expect(window.document).toExist(); - let document = TestUtils.renderIntoDocument( - {}}/> - ); - var result = TestUtils.findAllInRenderedTree(document, element => element.props.className === 'notification-modal warning'); - expect(result.length).toBeGreaterThan(0); - }); - - it('NotificationModal basic success render', ()=> { - expect(window.document).toExist(); - let document = TestUtils.renderIntoDocument( - {}}/> - ); - var result = TestUtils.findAllInRenderedTree(document, element => element.props.className === 'notification-modal success'); - expect(result.length).toBeGreaterThan(0); - }); -}); diff --git a/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js b/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js index 9ab18137cf..8f2b7e7e88 100644 --- a/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js +++ b/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js @@ -1,43 +1,152 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. */ -import expect from 'expect'; + import React from 'react'; + import TestUtils from 'react-addons-test-utils'; +import {mount} from 'enzyme'; import VersionController from 'nfvo-components/panel/versionController/VersionController.jsx'; -import {actionsEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; +import {actionsEnum, statusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; +import {scryRenderedDOMComponentsWithTestId} from 'test-utils/Util.js'; +import {VSPComponentsVersionControllerFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js'; describe('versionController UI Component', () => { + let onSave, onClose, onVersionSwitching = onSave = onClose = () => {return Promise.resolve();}; + const versionData = VSPComponentsVersionControllerFactory.build(); + const isFormDataValid = true; + const viewableVersions = versionData.viewableVersions; + const version = versionData.version; + const props = {onSave, onClose, isFormDataValid, viewableVersions, version, onVersionSwitching}; it('function does exist', () => { var renderer = TestUtils.createRenderer(); - renderer.render(); + renderer.render(); var renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); it('validating checkin function', () => { - - let versionController = TestUtils.renderIntoDocument({return Promise.resolve();}}/>); + let versionController = TestUtils.renderIntoDocument(); let cb = action => expect(action).toBe(actionsEnum.CHECK_IN); versionController.checkin(cb); + }); + + it('validating checkout function', () => { + let versionController = TestUtils.renderIntoDocument(); + let cb = action => expect(action).toBe(actionsEnum.CHECK_OUT); + versionController.checkout(cb); + }); + + it('validating submit function', () => { + let versionController = TestUtils.renderIntoDocument(); + let cb = action => expect(action).toBe(actionsEnum.SUBMIT); + versionController.submit(cb); + }); + + it('validating revert function', () => { + let versionController = TestUtils.renderIntoDocument(); + let cb = action => expect(action).toBe(actionsEnum.UNDO_CHECK_OUT); + versionController.revertCheckout(cb); + }); + + it('does not show the save button when no onSave available', () => { + let noSaveProps = {...props, onSave: null }; + let versionController = TestUtils.renderIntoDocument(); + let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-save-btn'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(0); + }); + + it('does not show the submit button when no callVCAction available', () => { + let callVCActionProps = {...props, callVCAction: null}; + let versionController = TestUtils.renderIntoDocument(); + let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-submit-btn'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(0); + }); + + it('does not show the revert button when no callVCAction available', () => { + let callVCActionProps = {...props, callVCAction: null}; + let versionController = TestUtils.renderIntoDocument(); + let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-revert-btn'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(0); + }); + + it('Shows the save button when onSave available', () => { + let versionController = TestUtils.renderIntoDocument(); + let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-save-btn'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + }); + + it('Shows the submit button when callVCAction available', () => { + let callVCActionProps = { ...props, callVCAction: function(){} }; + let versionController = TestUtils.renderIntoDocument(); + let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-submit-btn'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + }); + + it('Shows the revert button when callVCAction available', () => { + let callVCActionProps = { ...props, callVCAction: function(){} }; + let versionController = TestUtils.renderIntoDocument(); + let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-revert-btn'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + }); + + it('Shows the checkin button', () => { + let callVCActionProps = { ...props, callVCAction: function(){} }; + let versionController = TestUtils.renderIntoDocument(); + let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-checkout-btn'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + }); + + it('Shows the checkout button', () => { + let callVCActionProps = { ...props, callVCAction: function(){} }; + let versionController = TestUtils.renderIntoDocument(); + let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-checkout-btn'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + + }); + + it('Doesn\'t show the checkin button for prev version', () => { + let callVCActionProps = { ...props, version: '1.0', callVCAction: function(){} }; + let versionController = mount(); + let elem = versionController.find('[data-test-id="vc-checkout-btn"]'); + let svgIcon = versionController.find('.version-controller-lock-closed'); + + expect(elem).toBeTruthy(); + expect(elem.length).toEqual(1); + expect(svgIcon.hasClass('disabled')).toBe(true); + }); + + it('Doesn\'t show the checkout button', () => { + let callVCActionProps = { ...props, version: '1.0', callVCAction: function(){} }; + let versionController = mount(); + let elem = versionController.find('[data-test-id="vc-checkout-btn"]'); + let svgIcon = versionController.find('.version-controller-lock-closed'); + + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + expect(svgIcon.hasClass('disabled')).toBe(true); }); diff --git a/openecomp-ui/test/nfvo-components/panel/VersionController/versionControllerUtils.test.js b/openecomp-ui/test/nfvo-components/panel/VersionController/versionControllerUtils.test.js index 0e4a92118e..d654e16ddf 100644 --- a/openecomp-ui/test/nfvo-components/panel/VersionController/versionControllerUtils.test.js +++ b/openecomp-ui/test/nfvo-components/panel/VersionController/versionControllerUtils.test.js @@ -1,41 +1,38 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. */ -import expect from 'expect'; -import deepFreeze from 'deep-freeze'; + import Configuration from 'sdc-app/config/Configuration.js'; import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; import {statusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; const status = 'testStatus'; +const {lockingUser: currentUser, viewableVersions: defaultVersions} = VersionControllerUtilsFactory.build(); describe('versionController UI Component', () => { it('function does exist', () => { - expect(VersionControllerUtils).toExist(); + expect(VersionControllerUtils).toBeTruthy(); }); it('validating getCheckOutStatusKindByUserID - without "UserID"', () => { var result = VersionControllerUtils.getCheckOutStatusKindByUserID(status); expect(result.status).toBe(status); - expect(result.isCheckedOut).toBe(true); + expect(result.isCheckedOut).toBe(false); }); it('validating getCheckOutStatusKindByUserID - without "UserID" with locking user', () => { @@ -45,12 +42,11 @@ describe('versionController UI Component', () => { }); it('validating getCheckOutStatusKindByUserID - with "UserID" with configuration set', () => { - const userId = 'att'; - - Configuration.set('ATTUserID', userId); - var result = VersionControllerUtils.getCheckOutStatusKindByUserID(status, userId); - Configuration.set('ATTUserID', undefined); + const Uid = 'ecomp'; + Configuration.set('UserID', Uid); + var result = VersionControllerUtils.getCheckOutStatusKindByUserID(status, Uid); + Configuration.set('UserID', undefined); expect(result.status).toBe(status); expect(result.isCheckedOut).toBe(true); }); @@ -58,48 +54,31 @@ describe('versionController UI Component', () => { it('validating isCheckedOutByCurrentUser - when resource is not checked out', () => { - const currentUser = 'current'; - const resource = deepFreeze({ - version: '0.6', - viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'], - status: 'Final' - }); - - Configuration.set('ATTUserID', currentUser); + const resource = VersionControllerUtilsFactory.build({status: statusEnum.SUBMIT_STATUS}); + + Configuration.set('UserID', currentUser); const result = VersionControllerUtils.isCheckedOutByCurrentUser(resource); - Configuration.set('ATTUserID', undefined); + Configuration.set('UserID', undefined); expect(result).toBe(false); }); it('validating isCheckedOutByCurrentUser - when resource is checked out', () => { - const currentUser = 'current'; - const resource = deepFreeze({ - version: '0.6', - viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'], - status: 'Locked', - lockingUser: 'current' - }); - - Configuration.set('ATTUserID', currentUser); + const resource = VersionControllerUtilsFactory.build(); + + Configuration.set('UserID', currentUser); const result = VersionControllerUtils.isCheckedOutByCurrentUser(resource); - Configuration.set('ATTUserID', undefined); + Configuration.set('UserID', undefined); expect(result).toBe(true); }); it('validating isCheckedOutByCurrentUser - when resource is checked out by another user', () => { - const currentUser = 'current'; - const resource = deepFreeze({ - version: '0.6', - viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'], - status: 'Locked', - lockingUser: 'another' - }); - - Configuration.set('ATTUserID', currentUser); + const resource = VersionControllerUtilsFactory.build({lockingUser: 'another'}); + + Configuration.set('UserID', currentUser); const result = VersionControllerUtils.isCheckedOutByCurrentUser(resource); - Configuration.set('ATTUserID', undefined); + Configuration.set('UserID', undefined); expect(result).toBe(false); }); @@ -107,66 +86,43 @@ describe('versionController UI Component', () => { it('validating isReadOnly - when resource is not checked out', () => { - const currentUser = 'current'; - const resource = deepFreeze({ - version: '0.6', - viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'], - status: 'Final' - }); - - Configuration.set('ATTUserID', currentUser); + const resource = VersionControllerUtilsFactory.build({status: statusEnum.SUBMIT_STATUS}); + + Configuration.set('UserID', currentUser); const result = VersionControllerUtils.isReadOnly(resource); - Configuration.set('ATTUserID', undefined); + Configuration.set('UserID', undefined); expect(result).toBe(true); }); it('validating isReadOnly - when resource is checked out', () => { - const currentUser = 'current'; - const resource = deepFreeze({ - version: '0.6', - viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'], - status: 'Locked', - lockingUser: 'current' - }); - - Configuration.set('ATTUserID', currentUser); + const resource = VersionControllerUtilsFactory.build(); + + Configuration.set('UserID', currentUser); const result = VersionControllerUtils.isReadOnly(resource); - Configuration.set('ATTUserID', undefined); + Configuration.set('UserID', undefined); expect(result).toBe(false); }); it('validating isReadOnly - when version of resource is not latest', () => { - const currentUser = 'current'; - const resource = deepFreeze({ - version: '0.2', - viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'], - status: 'Locked', - lockingUser: 'current' - }); - - Configuration.set('ATTUserID', currentUser); + + const resource = VersionControllerUtilsFactory.build({version: defaultVersions[defaultVersions.length - 2]}); + + Configuration.set('UserID', currentUser); const result = VersionControllerUtils.isReadOnly(resource); - Configuration.set('ATTUserID', undefined); + Configuration.set('UserID', undefined); expect(result).toBe(true); }); it('validating isReadOnly - when resource is checked out by another user', () => { - const currentUser = 'current'; - const resource = deepFreeze({ - version: '0.6', - viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'], - status: 'Locked', - lockingUser: 'another' - }); - - Configuration.set('ATTUserID', currentUser); + const resource = VersionControllerUtilsFactory.build({lockingUser: 'another'}); + + Configuration.set('UserID', currentUser); const result = VersionControllerUtils.isReadOnly(resource); - Configuration.set('ATTUserID', undefined); + Configuration.set('UserID', undefined); expect(result).toBe(true); }); }); - diff --git a/openecomp-ui/test/nfvo-components/storyshots.test.js b/openecomp-ui/test/nfvo-components/storyshots.test.js new file mode 100644 index 0000000000..4d1bdbede0 --- /dev/null +++ b/openecomp-ui/test/nfvo-components/storyshots.test.js @@ -0,0 +1,2 @@ +import initStoryshots from 'storyshots'; +initStoryshots(); \ No newline at end of file -- cgit 1.2.3-korg