From b0f2f345cc2d1cc3812ad8a06fc1898daf5842d0 Mon Sep 17 00:00:00 2001 From: Adam Wudzinski Date: Tue, 26 Mar 2019 16:47:06 +0100 Subject: Remove unused code Remove unsed code from generic-components and change tests directory structure to reflect src structure Change-Id: Iada2efb0f7cfb05557eb7cd709b8a0ed75976b03 Issue-ID: AAI-1618 Signed-off-by: awudzins --- resources/scss/_components.scss | 3 - .../componentManager/ComponentManager.jsx | 306 ------------- .../componentManager/ComponentManagerConstants.js | 28 -- .../componentManager/ComponentManagerContainer.jsx | 111 ----- .../confirmations/ConfirmationModalView.jsx | 76 ---- .../dynamicViewLoader/DynamicViewLoaderActions.js | 33 -- .../DynamicViewLoaderConstants.js | 27 -- .../dynamicViewLoader/DynamicViewLoaderReducer.js | 37 -- .../dynamicViewLoader/dynamicViewLoader.jsx | 94 ---- src/generic-components/graph/SVGShape.jsx | 61 --- src/generic-components/input/SelectInput.jsx | 77 ---- src/generic-components/input/ToggleInput.jsx | 76 ---- .../input/inputOptions/InputOptions.jsx | 241 ---------- .../notifications/NotificationConstants.js | 29 -- .../notifications/NotificationModal.jsx | 121 ----- .../notifications/NotificationReducer.js | 48 -- src/generic-components/panel/SlidePanel.jsx | 137 ------ .../toggleButtonGroup/ToggleButtonGroup.jsx | 76 ---- .../toggleButtonGroup/ToggleButtonGroupActions.js | 27 -- .../ToggleButtonGroupConstants.js | 26 -- .../toggleButtonGroup/ToggleButtonGroupReducer.js | 34 -- src/generic-components/treeNode/TreeNode.jsx | 74 ---- test/MainScreenWrapperReducer.test.js | 486 --------------------- test/app/MainScreenWrapperReducer.test.js | 486 +++++++++++++++++++++ .../ConfigurableViewActions.test.js | 208 +++++++++ .../ConfigurableViewReducer.test.js | 54 +++ .../GlobalAutoCompleteSearchBar.test.js | 35 ++ .../GlobalAutoCompleteSearchBarReducer.test.js | 154 +++++++ .../GlobalInlineMessageBar.test.js | 37 ++ .../GlobalInlineMessageBarAction.test.js | 42 ++ .../GlobalInlineMessageBarReducer.test.js | 40 ++ test/app/networking/NetworkCalls.test.js | 124 ++++++ test/app/networking/NetworkUtil.test.js | 22 + test/app/tierSupport/SelectedNodeDetails.test.js | 141 ++++++ .../tierSupport/SelectedNodeDetailsReducer.test.js | 248 +++++++++++ test/app/tierSupport/TierSupportActions.test.js | 177 ++++++++ test/app/tierSupport/TierSupportReducer.test.js | 206 +++++++++ test/app/vnfSearch/VnfSearch.test.js | 49 +++ test/app/vnfSearch/VnfSearchActions.test.js | 215 +++++++++ .../vnfSearch/VnfSearchNfRoleVisualization.test.js | 154 +++++++ .../vnfSearch/VnfSearchNfTypeVisualization.test.js | 154 +++++++ ...nfSearchOrchestratedStatusVisualization.test.js | 154 +++++++ .../VnfSearchProvStatusVisualization.test.js | 154 +++++++ test/app/vnfSearch/VnfSearchReducer.test.js | 438 +++++++++++++++++++ .../VnfSearchTotalCountVisualization.test.js | 131 ++++++ .../AutoCompleteSearchBar.test.js | 40 -- .../ConfigurableViewActions.test.js | 208 --------- .../ConfigurableViewReducer.test.js | 54 --- .../AutoCompleteSearchBar.test.js | 40 ++ .../notifications/NotificationReducer.test.js | 197 --------- test/generic-components/treeNode/TreeNode.test.js | 41 -- .../GlobalAutoCompleteSearchBar.test.js | 35 -- .../GlobalAutoCompleteSearchBarReducer.test.js | 154 ------- .../GlobalInlineMessageBar.test.js | 37 -- .../GlobalInlineMessageBarAction.test.js | 42 -- .../GlobalInlineMessageBarReducer.test.js | 40 -- test/input/SelectInput.test.js | 13 - test/input/ToggleInput.test.js | 12 - test/networking/NetworkCalls.test.js | 124 ------ test/networking/NetworkUtil.test.js | 22 - test/tierSupport/SelectedNodeDetails.test.js | 141 ------ .../tierSupport/SelectedNodeDetailsReducer.test.js | 248 ----------- test/tierSupport/TierSupportActions.test.js | 177 -------- test/tierSupport/TierSupportReducer.test.js | 206 --------- test/vnfSearch/VnfSearch.test.js | 49 --- test/vnfSearch/VnfSearchActions.test.js | 215 --------- .../vnfSearch/VnfSearchNfRoleVisualization.test.js | 154 ------- .../vnfSearch/VnfSearchNfTypeVisualization.test.js | 154 ------- ...nfSearchOrchestratedStatusVisualization.test.js | 154 ------- .../VnfSearchProvStatusVisualization.test.js | 154 ------- test/vnfSearch/VnfSearchReducer.test.js | 438 ------------------- .../VnfSearchTotalCountVisualization.test.js | 131 ------ 72 files changed, 3463 insertions(+), 5468 deletions(-) delete mode 100644 src/generic-components/componentManager/ComponentManager.jsx delete mode 100644 src/generic-components/componentManager/ComponentManagerConstants.js delete mode 100644 src/generic-components/componentManager/ComponentManagerContainer.jsx delete mode 100644 src/generic-components/confirmations/ConfirmationModalView.jsx delete mode 100644 src/generic-components/dynamicViewLoader/DynamicViewLoaderActions.js delete mode 100644 src/generic-components/dynamicViewLoader/DynamicViewLoaderConstants.js delete mode 100644 src/generic-components/dynamicViewLoader/DynamicViewLoaderReducer.js delete mode 100644 src/generic-components/dynamicViewLoader/dynamicViewLoader.jsx delete mode 100644 src/generic-components/graph/SVGShape.jsx delete mode 100644 src/generic-components/input/SelectInput.jsx delete mode 100644 src/generic-components/input/ToggleInput.jsx delete mode 100644 src/generic-components/input/inputOptions/InputOptions.jsx delete mode 100644 src/generic-components/notifications/NotificationConstants.js delete mode 100644 src/generic-components/notifications/NotificationModal.jsx delete mode 100644 src/generic-components/notifications/NotificationReducer.js delete mode 100644 src/generic-components/panel/SlidePanel.jsx delete mode 100644 src/generic-components/toggleButtonGroup/ToggleButtonGroup.jsx delete mode 100644 src/generic-components/toggleButtonGroup/ToggleButtonGroupActions.js delete mode 100644 src/generic-components/toggleButtonGroup/ToggleButtonGroupConstants.js delete mode 100644 src/generic-components/toggleButtonGroup/ToggleButtonGroupReducer.js delete mode 100644 src/generic-components/treeNode/TreeNode.jsx delete mode 100644 test/MainScreenWrapperReducer.test.js create mode 100644 test/app/MainScreenWrapperReducer.test.js create mode 100644 test/app/configurableViews/ConfigurableViewActions.test.js create mode 100644 test/app/configurableViews/ConfigurableViewReducer.test.js create mode 100644 test/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBar.test.js create mode 100644 test/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.test.js create mode 100644 test/app/globalInlineMessageBar/GlobalInlineMessageBar.test.js create mode 100644 test/app/globalInlineMessageBar/GlobalInlineMessageBarAction.test.js create mode 100644 test/app/globalInlineMessageBar/GlobalInlineMessageBarReducer.test.js create mode 100644 test/app/networking/NetworkCalls.test.js create mode 100644 test/app/networking/NetworkUtil.test.js create mode 100644 test/app/tierSupport/SelectedNodeDetails.test.js create mode 100644 test/app/tierSupport/SelectedNodeDetailsReducer.test.js create mode 100644 test/app/tierSupport/TierSupportActions.test.js create mode 100644 test/app/tierSupport/TierSupportReducer.test.js create mode 100644 test/app/vnfSearch/VnfSearch.test.js create mode 100644 test/app/vnfSearch/VnfSearchActions.test.js create mode 100644 test/app/vnfSearch/VnfSearchNfRoleVisualization.test.js create mode 100644 test/app/vnfSearch/VnfSearchNfTypeVisualization.test.js create mode 100644 test/app/vnfSearch/VnfSearchOrchestratedStatusVisualization.test.js create mode 100644 test/app/vnfSearch/VnfSearchProvStatusVisualization.test.js create mode 100644 test/app/vnfSearch/VnfSearchReducer.test.js create mode 100644 test/app/vnfSearch/VnfSearchTotalCountVisualization.test.js delete mode 100644 test/autoCompleteSearchBar/AutoCompleteSearchBar.test.js delete mode 100644 test/configurableViews/ConfigurableViewActions.test.js delete mode 100644 test/configurableViews/ConfigurableViewReducer.test.js create mode 100644 test/generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.test.js delete mode 100644 test/generic-components/notifications/NotificationReducer.test.js delete mode 100644 test/generic-components/treeNode/TreeNode.test.js delete mode 100644 test/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBar.test.js delete mode 100644 test/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.test.js delete mode 100644 test/globalInlineMessageBar/GlobalInlineMessageBar.test.js delete mode 100644 test/globalInlineMessageBar/GlobalInlineMessageBarAction.test.js delete mode 100644 test/globalInlineMessageBar/GlobalInlineMessageBarReducer.test.js delete mode 100644 test/input/SelectInput.test.js delete mode 100644 test/input/ToggleInput.test.js delete mode 100644 test/networking/NetworkCalls.test.js delete mode 100644 test/networking/NetworkUtil.test.js delete mode 100644 test/tierSupport/SelectedNodeDetails.test.js delete mode 100644 test/tierSupport/SelectedNodeDetailsReducer.test.js delete mode 100644 test/tierSupport/TierSupportActions.test.js delete mode 100644 test/tierSupport/TierSupportReducer.test.js delete mode 100644 test/vnfSearch/VnfSearch.test.js delete mode 100644 test/vnfSearch/VnfSearchActions.test.js delete mode 100644 test/vnfSearch/VnfSearchNfRoleVisualization.test.js delete mode 100644 test/vnfSearch/VnfSearchNfTypeVisualization.test.js delete mode 100644 test/vnfSearch/VnfSearchOrchestratedStatusVisualization.test.js delete mode 100644 test/vnfSearch/VnfSearchProvStatusVisualization.test.js delete mode 100644 test/vnfSearch/VnfSearchReducer.test.js delete mode 100644 test/vnfSearch/VnfSearchTotalCountVisualization.test.js diff --git a/resources/scss/_components.scss b/resources/scss/_components.scss index ca926f0..2f696cc 100644 --- a/resources/scss/_components.scss +++ b/resources/scss/_components.scss @@ -20,12 +20,9 @@ */ @import "components/validationForm"; -@import "components/slidePanel"; -@import "components/toggleInput"; @import "components/notifications"; @import "components/dropdownMultiSelect"; @import "components/inlineMessage"; -@import "components/toggleButtonGroup"; @import "components/titledComponent"; @import "components/containerPanel"; @import "components/filterBar"; diff --git a/src/generic-components/componentManager/ComponentManager.jsx b/src/generic-components/componentManager/ComponentManager.jsx deleted file mode 100644 index 7b94279..0000000 --- a/src/generic-components/componentManager/ComponentManager.jsx +++ /dev/null @@ -1,306 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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 React, {Component} from 'react'; - -import ComponentManagerContainer from - 'generic-components/componentManager/ComponentManagerContainer.jsx'; -import { - MIN_PANEL_WIDTH, - MIN_PANEL_HEIGHT, - MAX_PANEL_WIDTH, - EDIT_ICON, - LAYOUT_STATIC -} from 'generic-components/componentManager/ComponentManagerConstants.js'; - -var widthProvider = require('react-grid-layout').WidthProvider; -var ReactGridLayout = require('react-grid-layout'); -ReactGridLayout = widthProvider(ReactGridLayout); - -export default class ComponentManager extends Component { - constructor(props) { - super(props); - - if (props.layoutType === LAYOUT_STATIC && - Object.keys(props.layoutFormat).length > 0) { - this.state = { - layout: props.layoutFormat.layout, - panels: props.layoutFormat.panels, - containers: props.layoutFormat.containers - }; - } else { - this.state = { - layout: [], - panels: [], - containers: [] - }; - } - this.onLayoutChange = this.onLayoutChange.bind(this); - } - - createContainer( - containerId, xPos, yPos, width, height, staticLayout = false) { - if (staticLayout) { - return { - id: containerId, - properties: { - x: xPos, - y: yPos, - w: width, - h: height, - isDraggable: false, - isResizable: false - } - }; - } else { - return { - id: containerId, - properties: { - x: xPos, - y: yPos, - w: width, - h: height, - minW: MIN_PANEL_WIDTH, - maxW: MAX_PANEL_WIDTH, - minH: MIN_PANEL_HEIGHT - } - }; - } - } - - createPanel(id, title, panelSource, panelProps, actionList) { - return { - id: id, - title: title, - source: panelSource, - props: panelProps, - actions: actionList - }; - } - - addNewComponent(compProps, containingContainerId) { - let containerId = containingContainerId; - let actionsList = []; - - if (typeof containerId === 'undefined' || containerId === null) { - // new component being added isn't associated with a - // container yet, so create one - containerId = 'container:' + (new Date).getTime(); - let updatedContainerProps = []; - this.state.containers.forEach((containerProps) => { - updatedContainerProps.push(containerProps); - }); - updatedContainerProps.push( - this.createContainer(containerId, 0, Infinity, 12, 2)); - this.setState({containers: updatedContainerProps}); - - actionsList = [ - { - type: 'close', id: containerId, callback: () => { - this.removeExistingComponent(containerId); - } - } - ]; - } else { - // we are updating a static container with a new panel, add the edit - // action so it can be updated moving forward - actionsList = [ - { - type: 'custom', - id: containingContainerId, - icon: EDIT_ICON, - callback: () => { - this.props.addPanelCallback(containingContainerId); - } - } - ]; - } - - let updatedPanelProps = []; - this.state.panels.forEach((panelProp) => { - if (panelProp.id !== containingContainerId) { - // add all existing panels except the one with a - // matching id (this is an edit scenario, will replace - // with new panel below - updatedPanelProps.push(panelProp); - } - }); - updatedPanelProps.push( - this.createPanel( - containerId, - compProps.title, - compProps.visualizationSource, - compProps.visualizationProps, - actionsList)); - this.setState({panels: updatedPanelProps}); - } - - removeExistingComponent(id) { - let updatedPanelProps = this.state.panels.filter((panelProp) => { - return id !== panelProp.id; - }); - this.setState({panels: updatedPanelProps}); - - let updatedContainerProps = this.state.containers.filter( - (containerProp) => { - return id !== containerProp.id; - }); - this.setState({containers: updatedContainerProps}); - } - - getLayoutProperties() { - return { - layout: this.state.layout, - containers: this.state.containers, - panels: this.state.panels - }; - } - - setLayoutProperties(layoutProperties) { - this.setState({ - layout: layoutProperties.layout, - containers: layoutProperties.containers, - panels: layoutProperties.panels - }); - } - - fetchMatchingPanel(containerId) { - let actionsList = []; - let matchingPanel = ( - - {'Please select a visualization'} - - ); - this.state.panels.forEach((panel) => { - if (panel.id === containerId) { - let GeneratedComponent = - this.props.componentPropertiesProvider[panel.source].component.class; - let visProps = panel.props; - matchingPanel = ( - - - - ); - } - }); - return matchingPanel; - } - - preparedContainers() { - let containersToRender = []; - - this.state.containers.forEach((container) => { - let matchingPanel = this.fetchMatchingPanel(container.id); - - containersToRender.push(
- {matchingPanel} -
); - }); - - return containersToRender; - } - - onLayoutChange(layout) { - this.setState({layout: layout}); - this.props.onLayoutChange(layout); - } - - buildStaticContainers(layoutFormat) { - let staticContainers = []; - let nextRowIndex = 0; - - layoutFormat.layout.forEach((row) => { - let nextColIndex = 0; - let currentTallestContainer = 0; - - row.forEach((col) => { - let containerId = 'container:' + nextRowIndex + '-' + nextColIndex; - let xPos = nextColIndex; - let yPos = nextRowIndex; - let width = 12 * col.width; - let height = col.height; - - nextColIndex = nextColIndex + width; - currentTallestContainer = Math.max(currentTallestContainer, col.height); - - staticContainers.push( - this.createContainer( - containerId, - xPos, - yPos, - width, - height, - true - ) - ); - }); - - nextRowIndex = currentTallestContainer; - }); - - return staticContainers; - } - - componentWillReceiveProps(nextProps) { - if (nextProps.layoutFormat !== this.props.layoutFormat) { - // layout format being passed in are the containers, panels and layout - // for the newly view - this.setState({ - layout: nextProps.layoutFormat.layout, - panels: nextProps.layoutFormat.panels, - containers: nextProps.layoutFormat.containers - }); - } - } - - render() { - - return ( -
- - {this.preparedContainers()} - -
- ); - } -} -ComponentManager.defaultProps = { - cols: 12, - rewHeight: 100, - onLayoutChange: function () { - }, - showHeader: true, - showTitle: true, - showBorder: true -}; diff --git a/src/generic-components/componentManager/ComponentManagerConstants.js b/src/generic-components/componentManager/ComponentManagerConstants.js deleted file mode 100644 index c2f5616..0000000 --- a/src/generic-components/componentManager/ComponentManagerConstants.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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========================================================= - */ -export const MIN_PANEL_WIDTH = 1; -export const MIN_PANEL_HEIGHT = 1; -export const MAX_PANEL_WIDTH = 12; - -export const EDIT_ICON = 'fa-pencil'; - -export const LAYOUT_STATIC = 'static'; -export const LAYOUT_DYNAMIC = 'dynamic'; diff --git a/src/generic-components/componentManager/ComponentManagerContainer.jsx b/src/generic-components/componentManager/ComponentManagerContainer.jsx deleted file mode 100644 index cd51d37..0000000 --- a/src/generic-components/componentManager/ComponentManagerContainer.jsx +++ /dev/null @@ -1,111 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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 React, {Component} from 'react'; -import { PropTypes } from 'prop-types'; -import ButtonGroup from 'react-bootstrap/lib/ButtonGroup'; -import Button from 'react-bootstrap/lib/Button'; - -import i18n from 'utils/i18n/i18n'; - -const ICON_CLASS_CLOSE = 'fa fa-times'; - -export default class ComponentManagerContainer extends Component { - - static propType = { - id: PropTypes.string, - title: PropTypes.string, - actions: PropTypes.array, - showHeader: PropTypes.bool, - showTitle: PropTypes.bool, - showBorder: PropTypes.bool, - }; - - static defaultProps = { - id: '', - title: 'Some Title', - actions: [], - showHeader: true, - showTitle: true, - showBorder: true - }; - - constructor(props) { - super(props); - } - - render() { - let { - title, - actions, - children, - showHeader, - showTitle, - showBorder - } = this.props; - let buttons = []; - actions.forEach((action) => { - switch (action.type) { - case 'close': - buttons.push( - - ); - break; - case 'custom': - buttons.push( - - ); - break; - } - }); - - let containerClass = showBorder - ? 'titled-container titled-container-boarders' - : 'titled-container'; - let headerClass = showHeader ? 'titled-container-header' : 'hidden'; - let titleClass = showTitle ? '' : 'hidden'; - - return ( -
- {buttons} -
- {i18n(title)} -
-
- {children} -
-
- ); - } -} diff --git a/src/generic-components/confirmations/ConfirmationModalView.jsx b/src/generic-components/confirmations/ConfirmationModalView.jsx deleted file mode 100644 index 39fea97..0000000 --- a/src/generic-components/confirmations/ConfirmationModalView.jsx +++ /dev/null @@ -1,76 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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 React from 'react'; -import { PropTypes } from 'prop-types'; -import Button from 'react-bootstrap/lib/Button.js'; - -import i18n from 'utils/i18n/i18n.js'; -import Modal from 'generic-components/modal/Modal.jsx'; - -let typeClass = { - 'default': 'primary', - error: 'danger', - warning: 'warning', - success: 'success' -}; - - -class ConfirmationModalView extends React.Component { - - static propTypes = { - show: PropTypes.bool, - type: PropTypes.oneOf(['default', 'error', 'warning', 'success']), - msg: PropTypes.node, - title: PropTypes.string, - confirmationDetails: PropTypes.object - }; - - static defaultProps = { - show: false, - type: 'warning', - title: 'Warning', - msg: '' - }; - - render() { - let {title, type, msg, show} = this.props; - - return ( - - - {title} - - {msg} - - - - - - ); - }; -} - -export default ConfirmationModalView; diff --git a/src/generic-components/dynamicViewLoader/DynamicViewLoaderActions.js b/src/generic-components/dynamicViewLoader/DynamicViewLoaderActions.js deleted file mode 100644 index 1d6a401..0000000 --- a/src/generic-components/dynamicViewLoader/DynamicViewLoaderActions.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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 { - dynamicViewLoaderActionTypes -} - from 'generic-components/dynamicViewLoader/DynamicViewLoaderConstants.js'; - -export function processLayoutSourceChange(layoutSource) { - return { - type: dynamicViewLoaderActionTypes.DVL_LAYOUT_SOURCE_CHANGE, - data: { - layoutSource: layoutSource - } - }; -} diff --git a/src/generic-components/dynamicViewLoader/DynamicViewLoaderConstants.js b/src/generic-components/dynamicViewLoader/DynamicViewLoaderConstants.js deleted file mode 100644 index 2afe167..0000000 --- a/src/generic-components/dynamicViewLoader/DynamicViewLoaderConstants.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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 keyMirror from 'utils/KeyMirror.js'; - -export const dynamicViewLoaderActionTypes = keyMirror({ - DVL_LAYOUT_SOURCE_CHANGE: null -}); - -export const DYNAMIC_VIEW_LOADER_TITLE = 'Dynamic View'; diff --git a/src/generic-components/dynamicViewLoader/DynamicViewLoaderReducer.js b/src/generic-components/dynamicViewLoader/DynamicViewLoaderReducer.js deleted file mode 100644 index 390856a..0000000 --- a/src/generic-components/dynamicViewLoader/DynamicViewLoaderReducer.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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 {combineReducers} from 'redux'; - -import {dynamicViewLoaderActionTypes} from 'generic-components/dynamicViewLoader/DynamicViewLoaderConstants.js'; - -export default combineReducers({ - dynamicViewLoadData: (state = {}, action) => { - switch (action.type) { - case dynamicViewLoaderActionTypes.DVL_LAYOUT_SOURCE_CHANGE: - return { - ...state, - layoutSource: action.data.layoutSource - }; - } - - return state; - } -}); diff --git a/src/generic-components/dynamicViewLoader/dynamicViewLoader.jsx b/src/generic-components/dynamicViewLoader/dynamicViewLoader.jsx deleted file mode 100644 index 7732951..0000000 --- a/src/generic-components/dynamicViewLoader/dynamicViewLoader.jsx +++ /dev/null @@ -1,94 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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 React, {Component} from 'react'; -import { PropTypes } from 'prop-types'; -import {connect} from 'react-redux'; - -import DateRangeSelector from 'generic-components/dateRangeSelector/DateRangeSelector.jsx'; -import ComponentManager from 'generic-components/componentManager/ComponentManager.jsx'; -import {DYNAMIC_VIEW_LOADER_TITLE} from 'generic-components/dynamicViewLoader/DynamicViewLoaderConstants.js'; -import {processLayoutSourceChange} from 'generic-components/dynamicViewLoader/DynamicViewLoaderActions.js'; -import {visualizationProviderProperties} from 'generic-components/dynamicViewLoader/VisualizationProvider.js'; -import {LAYOUT_STATIC} from 'generic-components/componentManager/ComponentManagerConstants.js'; - -import i18n from 'utils/i18n/i18n'; -import customViews from 'resources/views/customViews.json'; - -const mapStateToProps = - ({dynamicViewReducer: {dynamicViewLoadData}}) => { - let { - viewTitle = i18n(DYNAMIC_VIEW_LOADER_TITLE), - layoutSource = {} - } = dynamicViewLoadData; - - return { - viewTitle, - layoutSource - }; - }; - -let mapActionToProps = (dispatch) => { - return { - onLayoutSourceChange: (layoutSource) => { - dispatch(processLayoutSourceChange(layoutSource)); - } - }; -}; - -class DynamicViewLoader extends Component { - static propTypes = { - viewTitle: PropTypes.string, - layoutSource: PropTypes.object - }; - - componentWillMount() { - let viewName = this.props.location.pathname.split('/'); - - for (let view in customViews) { - if (customViews[view]['viewName'] === viewName[1]) { - this.props.onLayoutSourceChange(customViews[view]['layoutProperties']); - } - } - } - - render() { - let {viewTitle, layoutSource} = this.props; - - return ( -
-
- - {viewTitle} - - -
- -
- ); - } -} -export default connect(mapStateToProps, mapActionToProps)(DynamicViewLoader); diff --git a/src/generic-components/graph/SVGShape.jsx b/src/generic-components/graph/SVGShape.jsx deleted file mode 100644 index 8b33598..0000000 --- a/src/generic-components/graph/SVGShape.jsx +++ /dev/null @@ -1,61 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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 React, {Component} from 'react'; -import { PropTypes } from 'prop-types'; -import NodeVisualElementConstants from './NodeVisualElementConstants'; - -class SVGShape extends Component { - - static propTypes = { - shapeType: PropTypes.string.isRequired, - shapeAttributes: PropTypes.object.isRequired, - shapeClass: PropTypes.object.isRequired, - textValue: PropTypes.string - }; - - static defaultProps = { - shapeType: '', - shapeAttributes: {}, - shapeClass: {}, - textValue: '' - }; - - render() { - let {shapeType, shapeAttributes, shapeClass, textValue} = this.props; - - switch (shapeType) { - case NodeVisualElementConstants.SVG_CIRCLE: - return ; - - case NodeVisualElementConstants.SVG_LINELINE: - return ; - - case NodeVisualElementConstants.TEXT: - return {textValue}; - - default: - return undefined; - } - } -} - -export default SVGShape; diff --git a/src/generic-components/input/SelectInput.jsx b/src/generic-components/input/SelectInput.jsx deleted file mode 100644 index dbe6a20..0000000 --- a/src/generic-components/input/SelectInput.jsx +++ /dev/null @@ -1,77 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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========================================================= - */ -/** - * The HTML structure here is aligned with bootstrap HTML structure for form - * elements. In this way we have proper styling and it is aligned with other - * form elements on screen. - * - * Select and MultiSelect options: - * - * label - the label to be shown which paired with the input - * - * all other "react-select" props - as documented on - * http://jedwatson.github.io/react-select/ - * or - * https://github.com/JedWatson/react-select - */ -import React, {Component} from 'react'; -import Select from 'react-select'; -import 'react-select/dist/react-select.css'; - -class SelectInput extends Component { - - inputValue = []; - - render() { - let {label, value, ...other} = this.props; - return ( -
-
- {label && } - - -
-
- ); - } - - click = () => { - let value = !this.state.value; - this.setState({value}); - - let onChange = this.props.onChange; - if (onChange) { - onChange(value); - } - } - - getValue() { - return this.state.value; - } -} diff --git a/src/generic-components/input/inputOptions/InputOptions.jsx b/src/generic-components/input/inputOptions/InputOptions.jsx deleted file mode 100644 index bf17df1..0000000 --- a/src/generic-components/input/inputOptions/InputOptions.jsx +++ /dev/null @@ -1,241 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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 React from 'react'; -import { PropTypes } from 'prop-types'; -import i18n from 'utils/i18n/i18n.js'; -import classNames from 'classnames'; -import Select from 'generic-components/input/SelectInput.jsx'; - -export const other = {OTHER: 'Other'}; - -class InputOptions extends React.Component { - - static propTypes = { - values: PropTypes.arrayOf(PropTypes.shape({ - enum: PropTypes.string, - title: PropTypes.string - })), - isEnabledOther: PropTypes.bool, - title: PropTypes.string, - selectedValue: PropTypes.string, - multiSelectedEnum: PropTypes.array, - selectedEnum: PropTypes.string, - otherValue: PropTypes.string, - onEnumChange: PropTypes.func, - onOtherChange: PropTypes.func, - isRequired: PropTypes.bool, - isMultiSelect: PropTypes.bool - }; - - - static contextTypes = { - isReadOnlyMode: PropTypes.bool - }; - - state = { - otherInputDisabled: !this.props.otherValue - }; - - oldProps = { - selectedEnum: '', - otherValue: '', - multiSelectedEnum: [] - }; - - render() { - let {label, isRequired, values, otherValue, onOtherChange, isMultiSelect, onBlur, multiSelectedEnum, selectedEnum, hasError, validations, children} = this.props; - - let currentMultiSelectedEnum = []; - let currentSelectedEnum = ''; - let {otherInputDisabled} = this.state; - if (isMultiSelect) { - currentMultiSelectedEnum = multiSelectedEnum; - if (!otherInputDisabled) { - currentSelectedEnum = - multiSelectedEnum ? multiSelectedEnum.toString() : undefined; - } - } - else { - currentSelectedEnum = selectedEnum; - } - - let isReadOnlyMode = this.context.isReadOnlyMode; - - return ( -
- - {isMultiSelect && otherInputDisabled ? - onBlur()} - disabled={isReadOnlyMode || Boolean(this.props.disabled)} - onChange={ value => this.enumChanged(value)} - type='select'> - {values && - values.length && - values.map(val => this.renderOptions(val))} - {onOtherChange && } - {children} - - - {!otherInputDisabled &&
} - onBlur()} - onChange={() => this.changedOtherInput()}/> -
- } -
- ); - } - - renderOptions(val) { - return ( - - ); - } - - - renderMultiSelectOptions(values) { - let {onOtherChange} = this.props; - let optionsList = []; - if (onOtherChange) { - optionsList = values.map(option => { - return { - label: option.title, - value: option.enum, - }; - }).concat([{ - label: i18n(other.OTHER), - value: i18n(other.OTHER), - }]); - } - else { - optionsList = values.map(option => { - return { - label: option.title, - value: option.enum, - }; - }); - } - if (optionsList.length > 0 && optionsList[0].value === '') { - optionsList.shift(); - } - return optionsList; - } - - getValue() { - let res = ''; - let {isMultiSelect} = this.props; - let {otherInputDisabled} = this.state; - - if (otherInputDisabled) { - res = - isMultiSelect - ? this.refs._myInput.getValue() - : this.refs._myInput.value; - } else { - res = this.refs._otherValue.value; - } - return res; - } - - enumChanged() { - let enumValue = this.refs._myInput.value; - let {onEnumChange, isMultiSelect, onChange} = this.props; - this.setState({ - otherInputDisabled: enumValue !== other.OTHER - }); - if (onEnumChange) { - onEnumChange(isMultiSelect ? [enumValue] : enumValue); - } - - if (onChange) { - onChange(enumValue); - } - - } - - multiSelectEnumChanged(enumValue) { - let {onEnumChange} = this.props; - let selectedValues = enumValue.map(enumVal => { - return enumVal.value; - }); - - if (this.state.otherInputDisabled === false) { - selectedValues.shift(); - } - else if (selectedValues.includes(i18n(other.OTHER))) { - selectedValues = [i18n(other.OTHER)]; - } - - this.setState({ - otherInputDisabled: !selectedValues.includes(i18n(other.OTHER)) - }); - onEnumChange(selectedValues); - } - - changedOtherInput() { - let {onOtherChange} = this.props; - onOtherChange(this.refs._otherValue.value); - } - - componentDidUpdate() { - let {otherValue, selectedEnum, onInputChange, multiSelectedEnum} = this.props; - if (this.oldProps.otherValue !== otherValue - || this.oldProps.selectedEnum !== selectedEnum - || this.oldProps.multiSelectedEnum !== multiSelectedEnum) { - this.oldProps = { - otherValue, - selectedEnum, - multiSelectedEnum - }; - onInputChange(); - } - } - -} - -export default InputOptions; diff --git a/src/generic-components/notifications/NotificationConstants.js b/src/generic-components/notifications/NotificationConstants.js deleted file mode 100644 index 299ddaa..0000000 --- a/src/generic-components/notifications/NotificationConstants.js +++ /dev/null @@ -1,29 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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 keyMirror from 'utils/KeyMirror.js'; - -export default keyMirror({ - NOTIFY_ERROR: null, - NOTIFY_SUCCESS: null, - NOTIFY_WARNING: null, - NOTIFY_INFO: null, - NOTIFY_CLOSE: null -}); diff --git a/src/generic-components/notifications/NotificationModal.jsx b/src/generic-components/notifications/NotificationModal.jsx deleted file mode 100644 index 0e747d5..0000000 --- a/src/generic-components/notifications/NotificationModal.jsx +++ /dev/null @@ -1,121 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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========================================================= - */ -/** - * NotificationModal options: - * - * show: whether to show notification or not, - * type: the type of the notification. valid values are: 'default', 'error', - * 'warning', 'success' msg: the notification content. could be a string or - * node (React component) title: the notification title timeout: timeout for - * the notification to fade out. if timeout == 0 then the notification is - * rendered until the user closes it - * - */ -import React, {Component} from 'react'; -import { PropTypes } from 'prop-types'; -import {connect} from 'react-redux'; -import Button from 'react-bootstrap/lib/Button.js'; - -import i18n from 'utils/i18n/i18n.js'; -import Modal from 'generic-components/modal/Modal.jsx'; -import NotificationConstants from './NotificationConstants.js'; - -let typeClass = { - 'default': 'primary', - error: 'danger', - warning: 'warning', - success: 'success' -}; - -const mapActionsToProps = (dispatch) => { - return { - onCloseClick: () => dispatch({type: NotificationConstants.NOTIFY_CLOSE}) - }; -}; - -const mapStateToProps = ({notification}) => { - - let show = notification !== null && notification.title !== 'Conflict'; - let mapResult = {show}; - if (show) { - mapResult = {show, ...notification}; - } - - return mapResult; -}; - -class NotificationModal extends Component { - - static propTypes = { - show: PropTypes.bool, - type: PropTypes.oneOf(['default', 'error', 'warning', 'success']), - msg: PropTypes.node, - title: PropTypes.string, - timeout: PropTypes.number - }; - - static defaultProps = { - show: false, - type: 'default', - title: '', - msg: '', - timeout: 0 - }; - - state = {type: undefined}; - - componentWillReceiveProps(nextProps) { - if (this.props.show !== nextProps.show && nextProps.show === false) { - this.setState({type: this.props.type}); - } - else { - this.setState({type: undefined}); - } - } - - componentDidUpdate() { - if (this.props.timeout) { - setTimeout(this.props.onCloseClick, this.props.timeout); - } - } - - render() { - let {title, type, msg, show} = this.props; - if (!show) { - type = this.state.type; - } - return ( - - - {title} - - {msg} - - - - - ); - } -} - -export default connect(mapStateToProps, mapActionsToProps)(NotificationModal); diff --git a/src/generic-components/notifications/NotificationReducer.js b/src/generic-components/notifications/NotificationReducer.js deleted file mode 100644 index 1f5122c..0000000 --- a/src/generic-components/notifications/NotificationReducer.js +++ /dev/null @@ -1,48 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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 NotificationConstants from './NotificationConstants.js'; - -export default (state = null, action) => { - switch (action.type) { - case NotificationConstants.NOTIFY_INFO: - return createStatus('default', action); - case NotificationConstants.NOTIFY_ERROR: - return createStatus('error', action); - case NotificationConstants.NOTIFY_WARNING: - return createStatus('warning', action); - case NotificationConstants.NOTIFY_SUCCESS: - return createStatus('success', action); - case NotificationConstants.NOTIFY_CLOSE: - return null; - default: - return state; - } - -}; - -function createStatus(type, action) { - return { - type: type, - title: action.data.title, - msg: action.data.msg, - timeout: action.data.timeout - }; -} diff --git a/src/generic-components/panel/SlidePanel.jsx b/src/generic-components/panel/SlidePanel.jsx deleted file mode 100644 index 1550cee..0000000 --- a/src/generic-components/panel/SlidePanel.jsx +++ /dev/null @@ -1,137 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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 React from 'react'; -import { PropTypes } from 'prop-types'; -import FontAwesome from 'react-fontawesome'; -import ReactDOM from 'react-dom'; - -class SlidePanel extends React.Component { - - static PropTypes = { - direction: PropTypes.string.isRequired, - className: PropTypes.string, - title: PropTypes.string, - isOpen: PropTypes.bool - }; - - static defaultProps = { - title: '', - className: '', - isOpen: true - }; - - state = { - isOpen: this.props.isOpen, - direction: this.props.direction, - width: 0, - arrowWidth: 0 - }; - - componentDidMount() { - this.setSliderPosition(); - } - - componentDidUpdate() { - this.setSliderPosition(); - } - - render() { - - let {children, className} = this.props; - let {isOpen} = this.state; - - return ( -
- {this.renderHeader(isOpen)} -
{children}
-
- ); - } - - renderHeader(isOpen) { - let {direction: initialDirection, title} = this.props; - let {direction: currentDirection} = this.state; - - let iconName = currentDirection === - 'right' - ? 'angle-double-right collapse-double-icon' - : 'angle-double-left collapse-double-icon'; - - let awestyle = {padding: '5px'}; - - if (!isOpen && initialDirection === 'right') { - awestyle.marginLeft = '-1px'; - } - return ( -
- { initialDirection === 'left' && - {title}} - - { initialDirection === 'right' && - {title}} -
- ); - } - - handleClick = () => { - this.setState({ - isOpen: !this.state.isOpen, - direction: this.state.direction === 'left' ? 'right' : 'left' - }); - } - - setSliderPosition = () => { - - let el = ReactDOM.findDOMNode(this); - let {style} = el; - - let {direction: initialDirection} = this.props; - let arrowIconSize = Math.floor(ReactDOM.findDOMNode(this.refs.arrowIcon) - .getBoundingClientRect().width) * 2; - if (!this.state.isOpen) { - if (this.props.direction === 'left') { - style.left = arrowIconSize - el.getBoundingClientRect().width + 'px'; - } - if (initialDirection === 'right') { - style.right = arrowIconSize - el.getBoundingClientRect().width + 'px'; - } - } - else { - if (initialDirection === 'left') { - style.left = '0px'; - } - - if (this.props.direction === 'right') { - style.right = '0px'; - } - } - } - -} - -export default SlidePanel; diff --git a/src/generic-components/toggleButtonGroup/ToggleButtonGroup.jsx b/src/generic-components/toggleButtonGroup/ToggleButtonGroup.jsx deleted file mode 100644 index 0fe8939..0000000 --- a/src/generic-components/toggleButtonGroup/ToggleButtonGroup.jsx +++ /dev/null @@ -1,76 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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 React, {Component} from 'react'; -import { PropTypes } from 'prop-types'; -import {connect} from 'react-redux'; - -import ButtonGroup from 'react-bootstrap/lib/ButtonGroup.js'; -import Button from 'react-bootstrap/lib/Button.js'; - -import ToggleButtonGroupActions from 'generic-components/toggleButtonGroup/ToggleButtonGroupActions.js'; - -let mapActionToProps = (dispatch) => { - return { - onButtonToggle: (buttonName) => { - dispatch(ToggleButtonGroupActions.onToggle({button: buttonName})); - } - }; -}; - -let mapStateToProps = ({toggleButtonGroupData}) => { - - let {selectedButton} = toggleButtonGroupData; - - return { - selectedButton - }; -}; - -class ToggleButtonGroup extends Component { - - static propTypes = { - buttonDefinitions: PropTypes.object.isRequired - }; - - onButtonSelect(buttonName) { - this.props.onButtonToggle(buttonName); - } - - render() { - let {selectedButton, buttonDefinitions} = this.props; - let buttonListElements = []; - Object.keys(buttonDefinitions).map(function (item) { - buttonListElements.push( - - ); - }.bind(this)); - - return ( - - {buttonListElements} - - ); - } -} -export default connect(mapStateToProps, mapActionToProps)(ToggleButtonGroup); diff --git a/src/generic-components/toggleButtonGroup/ToggleButtonGroupActions.js b/src/generic-components/toggleButtonGroup/ToggleButtonGroupActions.js deleted file mode 100644 index a04d127..0000000 --- a/src/generic-components/toggleButtonGroup/ToggleButtonGroupActions.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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 ToggleButtonGroupConstants from './ToggleButtonGroupConstants.js'; - -export default { - onToggle(buttonName) { - return {type: ToggleButtonGroupConstants.BUTTON_TOGGLED, data: buttonName}; - } -}; diff --git a/src/generic-components/toggleButtonGroup/ToggleButtonGroupConstants.js b/src/generic-components/toggleButtonGroup/ToggleButtonGroupConstants.js deleted file mode 100644 index 47c458a..0000000 --- a/src/generic-components/toggleButtonGroup/ToggleButtonGroupConstants.js +++ /dev/null @@ -1,26 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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========================================================= - */ -// events -const BUTTON_TOGGLED = 'BUTTON_TOGGLED'; - -module.exports = { - BUTTON_TOGGLED: BUTTON_TOGGLED -}; diff --git a/src/generic-components/toggleButtonGroup/ToggleButtonGroupReducer.js b/src/generic-components/toggleButtonGroup/ToggleButtonGroupReducer.js deleted file mode 100644 index e5a069b..0000000 --- a/src/generic-components/toggleButtonGroup/ToggleButtonGroupReducer.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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 {BUTTON_TOGGLED} from 'generic-components/toggleButtonGroup/ToggleButtonGroupConstants.js'; - -export default (state = {}, action) => { - - switch (action.type) { - - case BUTTON_TOGGLED: - return { - ...state, - selectedButton: action.data.button - }; - } - return state; -}; diff --git a/src/generic-components/treeNode/TreeNode.jsx b/src/generic-components/treeNode/TreeNode.jsx deleted file mode 100644 index 2807ca4..0000000 --- a/src/generic-components/treeNode/TreeNode.jsx +++ /dev/null @@ -1,74 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * 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 React, {Component} from 'react'; -import classNames from 'classnames'; - - - - -class TreeNode extends Component { - - - constructor(props) { - super(props); - this.state = { - visible: false, - }; - } - - toggle = () => { - this.setState({visible: !this.state.visible}); - }; - - render() { - var childNodes; - var classObj; - if (this.props.node !== undefined && this.props.node.childNodes !== undefined) { - childNodes = this.props.node.childNodes.map(function (node, index) { - return
  • ; - }); - - classObj = { - togglable: true, - 'togglable-down': this.state.visible, - 'togglable-up': !this.state.visible - }; - } - - var style; - if (!this.state.visible) { - style = {display: 'none'}; - } - - return ( -
    - - {this.props.node.title} - -
      - {childNodes} -
    -
    - ); - } -} - -export default TreeNode; diff --git a/test/MainScreenWrapperReducer.test.js b/test/MainScreenWrapperReducer.test.js deleted file mode 100644 index e9324cc..0000000 --- a/test/MainScreenWrapperReducer.test.js +++ /dev/null @@ -1,486 +0,0 @@ -import thunk from 'redux-thunk'; -import randstr from 'randomstring'; -import configureMockStore from 'redux-mock-store'; - -import MainScreenWrapperReducer from 'app/MainScreenWrapperReducer' -import {aaiActionTypes} from 'app/MainScreenWrapperConstants'; -import {getPersonalizationDetails} from 'app/personlaization/PersonalizationActions'; -import {getInvalidSearchInputEvent} from'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarActions'; -import {extensibleViewNetworkCallback, showMainMenu, clearExtensibleViewData, setSecondaryTitle} from 'app/MainScreenWrapperActionHelper'; -import {externalUrlRequest, getSubscriptionPayload} from 'app/contextHandler/ContextHandlerActions' - -import {globalInlineMessageBarActionTypes} from "app/globalInlineMessageBar/GlobalInlineMessageBarConstants"; -import {globalAutoCompleteSearchBarActionTypes} from "app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants"; -import { - contextHandlerActionTypes, - FAILED_REQUEST, - MULTIPLE_RESULT, SUBSCRIPTION_FAILED_MESSAGE, - WRONG_EXTERNAL_REQUEST_MESSAGE, - WRONG_RESULT, - ZERO_RESULT -} from "app/contextHandler/ContextHandlerConstants"; -import {PERSONALIZATION_FAILED_MESSAGE, personalizationActionTypes} from "app/personlaization/PersonalizationConstans"; - -describe('MainScreenWrapperReducerTests', () => { - fetch = require('jest-fetch-mock'); - const mockStore = configureMockStore([thunk])(); - const initialState = {Baz : 'Fooo'}; - const error = '401'; - - beforeEach(() => { - fetch.resetMocks(); - mockStore.clearActions(); - }); - - describe('extensibleViewNetworkCallbackTests', () => { - const paramName = 'boo'; - const postBody = 'baz'; - const curView = {Boz : 'Fooz'}; - const requestUrl = 'www.foo.com'; - const response = {Foo: 'Bar'}; - - describe('success tests', () => { - beforeEach(async () => { - //given - fetch.once(JSON.stringify(response)); - await mockStore.dispatch(extensibleViewNetworkCallback(requestUrl, postBody, paramName, curView)); - }); - - it('action on success test', () => { - //when - const [action, ...rest] = mockStore.getActions(); - - //then - expect(rest).toEqual([]); - expect(action.type).toBe(aaiActionTypes.EXTENSIBLE_VIEW_NETWORK_CALLBACK_RESPONSE_RECEIVED); - }); - - it('reducer on success test', () => { - //given - const [action, ..._] = mockStore.getActions(); - - //when - const { - extensibleViewNetworkCallbackData, - ...rest - } = MainScreenWrapperReducer(initialState, action); - - //then - expect(rest).toEqual(initialState); - expect(extensibleViewNetworkCallbackData).toEqual({ - boo: response, - ...curView - }); - }); - }); - - describe('failure tests', () => { - beforeEach(async () => { - //given - fetch.mockRejectOnce(error); - await mockStore.dispatch(extensibleViewNetworkCallback(requestUrl, postBody, paramName, curView)); - }); - - it('action on failure test', () => { - //given - const [firstAction, secondAction, ...tail] = mockStore.getActions(); - - //then - expect(tail).toEqual([]); - expect(firstAction.type).toEqual(globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE); - expect(secondAction.type).toEqual(aaiActionTypes.EXTENSIBLE_VIEW_NETWORK_CALLBACK_RESPONSE_RECEIVED); - }); - - it('reducer on failure test', () => { - //given - const [firstAction, secondAction, ..._] = mockStore.getActions(); - - //when - const afterFirstState = MainScreenWrapperReducer(initialState, firstAction); - const { - extensibleViewNetworkCallbackData, - ...rest - } = MainScreenWrapperReducer(initialState, secondAction); - - //then - expect(afterFirstState).toEqual(initialState); - expect(rest).toEqual(initialState); - expect(extensibleViewNetworkCallbackData).toEqual({ - boo: {}, - ...curView - }); - }); - }); - }); - - describe.each([true, false])('showMainMenuTests', value => { - beforeEach(async () => { - //given - await mockStore.dispatch(showMainMenu(value)); - }); - - it('action on show: ' + value + ' test', () => { - //when - const [action, ...rest] = mockStore.getActions(); - - //then - expect(rest).toEqual([]); - expect(action.type).toBe(aaiActionTypes.AAI_SHOW_MENU); - }); - - it('reducer on show: ' + value + ' test', () => { - //given - const [action, ..._] = mockStore.getActions(); - - //when - const { - showMenu, - toggleButtonActive, - ...rest - } = MainScreenWrapperReducer(initialState, action); - - //then - expect(rest).toEqual(initialState); - expect(showMenu).toBe(value); - expect(toggleButtonActive).toBe(value); - }); - }); - - describe('clearExtensibleViewDataTests', () => { - beforeEach(async () => { - //given - await mockStore.dispatch(clearExtensibleViewData()); - }); - - it('action test', () => { - //when - const [action, ...rest] = mockStore.getActions(); - - //then - expect(rest).toEqual([]); - expect(action.type).toBe(aaiActionTypes.EXTENSIBLE_VIEW_NETWORK_CALLBACK_CLEAR_DATA); - }); - - it('reducer test', () => { - //given - const [action, ..._] = mockStore.getActions(); - - //when - const { - extensibleViewNetworkCallbackData, - ...rest - } = MainScreenWrapperReducer(initialState, action); - - expect(rest).toEqual(initialState); - expect(extensibleViewNetworkCallbackData).toEqual({}); - }); - }); - - describe('getInvalidSearchInputEventTests', () => { - const msg = randstr.generate(); - - beforeEach(async () => { - await mockStore.dispatch(getInvalidSearchInputEvent(msg)); - }); - - it('action msg: ' + msg + ' test', () => { - //when - const [action, ...rest] = mockStore.getActions(); - - //then - expect(rest).toEqual([]); - expect(action.type).toBe(globalAutoCompleteSearchBarActionTypes.SEARCH_WARNING_EVENT); - }); - - it('reducer msg: ' + msg + ' test', () => { - //given - const [action, ..._] = mockStore.getActions(); - - //when - const { - extensibleViewNetworkCallbackData, - ...rest - } = MainScreenWrapperReducer(initialState, action); - - //then - expect(rest).toEqual(initialState); - expect(extensibleViewNetworkCallbackData).toEqual({clearView : true}); - }); - }); - - describe('externalUrlRequestTests', () => { - const someUrlParams = 'view=A&entityId=B&entityType=C'; - - describe.each([{ - title: 'on empty url params', - prepareMock: () => {}, - urlParams: '', - expectedResponse: WRONG_EXTERNAL_REQUEST_MESSAGE - }, { - title: 'on request rejected by the server', - prepareMock: () => fetch.mockRejectOnce('401'), - urlParams: someUrlParams, - expectedResponse: FAILED_REQUEST - }, { - title: 'on empty suggestions', - prepareMock: () => fetch.once(JSON.stringify({})), - urlParams: someUrlParams, - expectedResponse: WRONG_RESULT - }, { - title: 'on no results', - prepareMock: () => fetch.once(JSON.stringify({totalFound: 0, suggestions: []})), - urlParams: someUrlParams, - expectedResponse: ZERO_RESULT - }, { - title: 'on multiple results', - prepareMock: () => fetch.once(JSON.stringify({totalFound: 2, suggestions: ['Foo', 'Bar']})), - urlParams: someUrlParams, - expectedResponse: MULTIPLE_RESULT - }])('failure tests', ({title, prepareMock, urlParams, expectedResponse}) => { - beforeEach(async () => { - //given - prepareMock(); - await mockStore.dispatch(externalUrlRequest(urlParams)); - }); - - it('action ' + title + ' test', () => { - //when - const [action, ...rest] = mockStore.getActions(); - - //then - expect(rest).toEqual([]); - expect(action.type).toBe(globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE); - expect(action.data.msgText).toEqual(expectedResponse); - }); - - it('reducer ' + title + ' test', () => { - //given - const [action, ..._] = mockStore.getActions(); - - //when - const state = MainScreenWrapperReducer(initialState, action); - - //then - expect(state).toEqual(initialState); - }); - }); - - describe("success tests", () => { - //given - const response = {totalFound: 1, suggestions: ['Foo']}; - - beforeEach(async () => { - //given - fetch.resetMocks(); - fetch.once(JSON.stringify(response)); - - await mockStore.dispatch(externalUrlRequest(someUrlParams)); - }); - - it('action on exactly one suggestion test', () => { - //when - const [firstAction, secondAction, ...rest] = mockStore.getActions(); - - //then - expect(rest).toEqual([]); - expect(firstAction.type).toBe( globalInlineMessageBarActionTypes.CLEAR_GLOBAL_MESSAGE); - expect(secondAction.type).toBe(contextHandlerActionTypes.SINGLE_SUGGESTION_FOUND); - }); - - it('reducer on exactly one suggestion test', () => { - //given - const [firstAction, secondAction, ..._] = mockStore.getActions(); - - //when - const state = MainScreenWrapperReducer(initialState, firstAction); - const { - externalRequestFound, - ...rest - } = MainScreenWrapperReducer(state, secondAction); - - //then - expect(state).toEqual(initialState); - expect(rest).toEqual(initialState); - expect(externalRequestFound).toEqual({suggestion: response.suggestions[0]}); - }); - }); - }); - - describe('setSecondaryTitleTests', () => { - //given - const title = randstr.generate(); - - beforeEach(async () => { - //given - await mockStore.dispatch(setSecondaryTitle(title)); - }); - - it('action test', () => { - //when - const [action, ...rest] = mockStore.getActions(); - - //then - expect(rest).toEqual([]); - expect(action.type).toBe(aaiActionTypes.SET_SECONDARY_TITLE); - }); - - it('reducer test', () => { - //given - const [action, ..._] = mockStore.getActions(); - - //when - const { - secondaryTitle, - ...rest - } = MainScreenWrapperReducer(initialState, action); - - //then - expect(rest).toEqual(initialState); - expect(secondaryTitle).toEqual(title); - }); - }); - - describe('getSubscriptionPayloadTests', () => { - describe('failure tests', () => { - beforeEach(async () => { - //given - fetch.mockRejectOnce(error); - await mockStore.dispatch(getSubscriptionPayload()); - }); - - it('action on request rejected by server test', async () => { - //when - const [action, ...rest] = mockStore.getActions(); - - //then - expect(rest).toEqual([]); - expect(action.type).toBe(globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE); - expect(action.data.msgText).toEqual(SUBSCRIPTION_FAILED_MESSAGE); - }); - - it('reducer on request rejected by server test', async () => { - //given - const [action, ..._] = mockStore.getActions(); - - //when - const state = MainScreenWrapperReducer(initialState, action); - - //then - expect(state).toEqual(initialState); - }); - }); - - const subscriptionData = 'Foo'; - - describe.each([{ - title: 'on disabled subscription', - payload: {subscriptionEnabled: false}, - type: contextHandlerActionTypes.SUBSCRIPTION_PAYLOAD_EMPTY, - detail : undefined - }, { - title: 'on enabled subscription', - payload: {subscriptionEnabled: true, subscriptionDetails: subscriptionData}, - type: contextHandlerActionTypes.SUBSCRIPTION_PAYLOAD_FOUND, - detail : subscriptionData - }])('success tests', ({title, payload, type, detail}) => { - beforeEach(async () => { - //given - fetch.once(JSON.stringify(payload)); - await mockStore.dispatch(getSubscriptionPayload()); - }); - - it('action ' + title + ' test', () => { - //when - const [action, ...rest] = mockStore.getActions(); - - //then - expect(rest).toEqual([]); - expect(action.type).toBe(type); - }); - - it('reducer ' + title + ' test', () => { - //given - const [action, ..._] = mockStore.getActions(); - - //when - const { - subscriptionEnabled, - subscriptionPayload, - ...rest - } = MainScreenWrapperReducer(initialState, action); - - //then - expect(rest).toEqual(initialState); - expect(subscriptionEnabled).toBe(payload.subscriptionEnabled); - expect(subscriptionPayload).toEqual(detail); - }); - }); - }); - - describe("getPersonalizationDetailsTests", () => { - describe('failure tests', () => { - beforeEach(async () => { - //given - fetch.mockRejectOnce(error); - await mockStore.dispatch(getPersonalizationDetails()); - }); - - it('action on request rejected by server test', () => { - //when - const [action, ...rest] = mockStore.getActions(); - - //then - expect(rest).toEqual([]); - expect(action.type).toBe(globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE); - expect(action.data.msgText).toEqual(PERSONALIZATION_FAILED_MESSAGE); - }); - - it('reducer on request rejected by server test', () => { - //given - const [action, ..._] = mockStore.getActions(); - - //when - const state = MainScreenWrapperReducer(initialState, action); - - //then - expect(state).toEqual(initialState); - }); - }); - - describe('success tests', () => { - const personalizationPayload = {topLeftHeader: 'Foo', htmlDocumentTitle: 'Bar'}; - - beforeEach(async () => { - //given - fetch.once(JSON.stringify(personalizationPayload)); - await mockStore.dispatch(getPersonalizationDetails()); - }); - - it('action on personalization payload found test', () => { - //when - const [action, ...rest] = mockStore.getActions(); - - //then - expect(rest).toEqual([]); - expect(action.type).toBe(personalizationActionTypes.PERSONALIZATION_PAYLOAD_FOUND); - }); - - it("Reducer on personalization payload found test", async () => { - //given - const [action, ..._] = mockStore.getActions(); - - //when - const { - aaiTopLeftPersonalizedHeader, - aaiPersonalizedHtmlDocumentTitle, - ...rest - } = MainScreenWrapperReducer(initialState, action); - - //then - expect(rest).toEqual(initialState); - expect(aaiTopLeftPersonalizedHeader).toEqual(personalizationPayload.topLeftHeader); - expect(aaiPersonalizedHtmlDocumentTitle).toEqual(personalizationPayload.htmlDocumentTitle); - }); - }); - }); -}); diff --git a/test/app/MainScreenWrapperReducer.test.js b/test/app/MainScreenWrapperReducer.test.js new file mode 100644 index 0000000..e9324cc --- /dev/null +++ b/test/app/MainScreenWrapperReducer.test.js @@ -0,0 +1,486 @@ +import thunk from 'redux-thunk'; +import randstr from 'randomstring'; +import configureMockStore from 'redux-mock-store'; + +import MainScreenWrapperReducer from 'app/MainScreenWrapperReducer' +import {aaiActionTypes} from 'app/MainScreenWrapperConstants'; +import {getPersonalizationDetails} from 'app/personlaization/PersonalizationActions'; +import {getInvalidSearchInputEvent} from'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarActions'; +import {extensibleViewNetworkCallback, showMainMenu, clearExtensibleViewData, setSecondaryTitle} from 'app/MainScreenWrapperActionHelper'; +import {externalUrlRequest, getSubscriptionPayload} from 'app/contextHandler/ContextHandlerActions' + +import {globalInlineMessageBarActionTypes} from "app/globalInlineMessageBar/GlobalInlineMessageBarConstants"; +import {globalAutoCompleteSearchBarActionTypes} from "app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants"; +import { + contextHandlerActionTypes, + FAILED_REQUEST, + MULTIPLE_RESULT, SUBSCRIPTION_FAILED_MESSAGE, + WRONG_EXTERNAL_REQUEST_MESSAGE, + WRONG_RESULT, + ZERO_RESULT +} from "app/contextHandler/ContextHandlerConstants"; +import {PERSONALIZATION_FAILED_MESSAGE, personalizationActionTypes} from "app/personlaization/PersonalizationConstans"; + +describe('MainScreenWrapperReducerTests', () => { + fetch = require('jest-fetch-mock'); + const mockStore = configureMockStore([thunk])(); + const initialState = {Baz : 'Fooo'}; + const error = '401'; + + beforeEach(() => { + fetch.resetMocks(); + mockStore.clearActions(); + }); + + describe('extensibleViewNetworkCallbackTests', () => { + const paramName = 'boo'; + const postBody = 'baz'; + const curView = {Boz : 'Fooz'}; + const requestUrl = 'www.foo.com'; + const response = {Foo: 'Bar'}; + + describe('success tests', () => { + beforeEach(async () => { + //given + fetch.once(JSON.stringify(response)); + await mockStore.dispatch(extensibleViewNetworkCallback(requestUrl, postBody, paramName, curView)); + }); + + it('action on success test', () => { + //when + const [action, ...rest] = mockStore.getActions(); + + //then + expect(rest).toEqual([]); + expect(action.type).toBe(aaiActionTypes.EXTENSIBLE_VIEW_NETWORK_CALLBACK_RESPONSE_RECEIVED); + }); + + it('reducer on success test', () => { + //given + const [action, ..._] = mockStore.getActions(); + + //when + const { + extensibleViewNetworkCallbackData, + ...rest + } = MainScreenWrapperReducer(initialState, action); + + //then + expect(rest).toEqual(initialState); + expect(extensibleViewNetworkCallbackData).toEqual({ + boo: response, + ...curView + }); + }); + }); + + describe('failure tests', () => { + beforeEach(async () => { + //given + fetch.mockRejectOnce(error); + await mockStore.dispatch(extensibleViewNetworkCallback(requestUrl, postBody, paramName, curView)); + }); + + it('action on failure test', () => { + //given + const [firstAction, secondAction, ...tail] = mockStore.getActions(); + + //then + expect(tail).toEqual([]); + expect(firstAction.type).toEqual(globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE); + expect(secondAction.type).toEqual(aaiActionTypes.EXTENSIBLE_VIEW_NETWORK_CALLBACK_RESPONSE_RECEIVED); + }); + + it('reducer on failure test', () => { + //given + const [firstAction, secondAction, ..._] = mockStore.getActions(); + + //when + const afterFirstState = MainScreenWrapperReducer(initialState, firstAction); + const { + extensibleViewNetworkCallbackData, + ...rest + } = MainScreenWrapperReducer(initialState, secondAction); + + //then + expect(afterFirstState).toEqual(initialState); + expect(rest).toEqual(initialState); + expect(extensibleViewNetworkCallbackData).toEqual({ + boo: {}, + ...curView + }); + }); + }); + }); + + describe.each([true, false])('showMainMenuTests', value => { + beforeEach(async () => { + //given + await mockStore.dispatch(showMainMenu(value)); + }); + + it('action on show: ' + value + ' test', () => { + //when + const [action, ...rest] = mockStore.getActions(); + + //then + expect(rest).toEqual([]); + expect(action.type).toBe(aaiActionTypes.AAI_SHOW_MENU); + }); + + it('reducer on show: ' + value + ' test', () => { + //given + const [action, ..._] = mockStore.getActions(); + + //when + const { + showMenu, + toggleButtonActive, + ...rest + } = MainScreenWrapperReducer(initialState, action); + + //then + expect(rest).toEqual(initialState); + expect(showMenu).toBe(value); + expect(toggleButtonActive).toBe(value); + }); + }); + + describe('clearExtensibleViewDataTests', () => { + beforeEach(async () => { + //given + await mockStore.dispatch(clearExtensibleViewData()); + }); + + it('action test', () => { + //when + const [action, ...rest] = mockStore.getActions(); + + //then + expect(rest).toEqual([]); + expect(action.type).toBe(aaiActionTypes.EXTENSIBLE_VIEW_NETWORK_CALLBACK_CLEAR_DATA); + }); + + it('reducer test', () => { + //given + const [action, ..._] = mockStore.getActions(); + + //when + const { + extensibleViewNetworkCallbackData, + ...rest + } = MainScreenWrapperReducer(initialState, action); + + expect(rest).toEqual(initialState); + expect(extensibleViewNetworkCallbackData).toEqual({}); + }); + }); + + describe('getInvalidSearchInputEventTests', () => { + const msg = randstr.generate(); + + beforeEach(async () => { + await mockStore.dispatch(getInvalidSearchInputEvent(msg)); + }); + + it('action msg: ' + msg + ' test', () => { + //when + const [action, ...rest] = mockStore.getActions(); + + //then + expect(rest).toEqual([]); + expect(action.type).toBe(globalAutoCompleteSearchBarActionTypes.SEARCH_WARNING_EVENT); + }); + + it('reducer msg: ' + msg + ' test', () => { + //given + const [action, ..._] = mockStore.getActions(); + + //when + const { + extensibleViewNetworkCallbackData, + ...rest + } = MainScreenWrapperReducer(initialState, action); + + //then + expect(rest).toEqual(initialState); + expect(extensibleViewNetworkCallbackData).toEqual({clearView : true}); + }); + }); + + describe('externalUrlRequestTests', () => { + const someUrlParams = 'view=A&entityId=B&entityType=C'; + + describe.each([{ + title: 'on empty url params', + prepareMock: () => {}, + urlParams: '', + expectedResponse: WRONG_EXTERNAL_REQUEST_MESSAGE + }, { + title: 'on request rejected by the server', + prepareMock: () => fetch.mockRejectOnce('401'), + urlParams: someUrlParams, + expectedResponse: FAILED_REQUEST + }, { + title: 'on empty suggestions', + prepareMock: () => fetch.once(JSON.stringify({})), + urlParams: someUrlParams, + expectedResponse: WRONG_RESULT + }, { + title: 'on no results', + prepareMock: () => fetch.once(JSON.stringify({totalFound: 0, suggestions: []})), + urlParams: someUrlParams, + expectedResponse: ZERO_RESULT + }, { + title: 'on multiple results', + prepareMock: () => fetch.once(JSON.stringify({totalFound: 2, suggestions: ['Foo', 'Bar']})), + urlParams: someUrlParams, + expectedResponse: MULTIPLE_RESULT + }])('failure tests', ({title, prepareMock, urlParams, expectedResponse}) => { + beforeEach(async () => { + //given + prepareMock(); + await mockStore.dispatch(externalUrlRequest(urlParams)); + }); + + it('action ' + title + ' test', () => { + //when + const [action, ...rest] = mockStore.getActions(); + + //then + expect(rest).toEqual([]); + expect(action.type).toBe(globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE); + expect(action.data.msgText).toEqual(expectedResponse); + }); + + it('reducer ' + title + ' test', () => { + //given + const [action, ..._] = mockStore.getActions(); + + //when + const state = MainScreenWrapperReducer(initialState, action); + + //then + expect(state).toEqual(initialState); + }); + }); + + describe("success tests", () => { + //given + const response = {totalFound: 1, suggestions: ['Foo']}; + + beforeEach(async () => { + //given + fetch.resetMocks(); + fetch.once(JSON.stringify(response)); + + await mockStore.dispatch(externalUrlRequest(someUrlParams)); + }); + + it('action on exactly one suggestion test', () => { + //when + const [firstAction, secondAction, ...rest] = mockStore.getActions(); + + //then + expect(rest).toEqual([]); + expect(firstAction.type).toBe( globalInlineMessageBarActionTypes.CLEAR_GLOBAL_MESSAGE); + expect(secondAction.type).toBe(contextHandlerActionTypes.SINGLE_SUGGESTION_FOUND); + }); + + it('reducer on exactly one suggestion test', () => { + //given + const [firstAction, secondAction, ..._] = mockStore.getActions(); + + //when + const state = MainScreenWrapperReducer(initialState, firstAction); + const { + externalRequestFound, + ...rest + } = MainScreenWrapperReducer(state, secondAction); + + //then + expect(state).toEqual(initialState); + expect(rest).toEqual(initialState); + expect(externalRequestFound).toEqual({suggestion: response.suggestions[0]}); + }); + }); + }); + + describe('setSecondaryTitleTests', () => { + //given + const title = randstr.generate(); + + beforeEach(async () => { + //given + await mockStore.dispatch(setSecondaryTitle(title)); + }); + + it('action test', () => { + //when + const [action, ...rest] = mockStore.getActions(); + + //then + expect(rest).toEqual([]); + expect(action.type).toBe(aaiActionTypes.SET_SECONDARY_TITLE); + }); + + it('reducer test', () => { + //given + const [action, ..._] = mockStore.getActions(); + + //when + const { + secondaryTitle, + ...rest + } = MainScreenWrapperReducer(initialState, action); + + //then + expect(rest).toEqual(initialState); + expect(secondaryTitle).toEqual(title); + }); + }); + + describe('getSubscriptionPayloadTests', () => { + describe('failure tests', () => { + beforeEach(async () => { + //given + fetch.mockRejectOnce(error); + await mockStore.dispatch(getSubscriptionPayload()); + }); + + it('action on request rejected by server test', async () => { + //when + const [action, ...rest] = mockStore.getActions(); + + //then + expect(rest).toEqual([]); + expect(action.type).toBe(globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE); + expect(action.data.msgText).toEqual(SUBSCRIPTION_FAILED_MESSAGE); + }); + + it('reducer on request rejected by server test', async () => { + //given + const [action, ..._] = mockStore.getActions(); + + //when + const state = MainScreenWrapperReducer(initialState, action); + + //then + expect(state).toEqual(initialState); + }); + }); + + const subscriptionData = 'Foo'; + + describe.each([{ + title: 'on disabled subscription', + payload: {subscriptionEnabled: false}, + type: contextHandlerActionTypes.SUBSCRIPTION_PAYLOAD_EMPTY, + detail : undefined + }, { + title: 'on enabled subscription', + payload: {subscriptionEnabled: true, subscriptionDetails: subscriptionData}, + type: contextHandlerActionTypes.SUBSCRIPTION_PAYLOAD_FOUND, + detail : subscriptionData + }])('success tests', ({title, payload, type, detail}) => { + beforeEach(async () => { + //given + fetch.once(JSON.stringify(payload)); + await mockStore.dispatch(getSubscriptionPayload()); + }); + + it('action ' + title + ' test', () => { + //when + const [action, ...rest] = mockStore.getActions(); + + //then + expect(rest).toEqual([]); + expect(action.type).toBe(type); + }); + + it('reducer ' + title + ' test', () => { + //given + const [action, ..._] = mockStore.getActions(); + + //when + const { + subscriptionEnabled, + subscriptionPayload, + ...rest + } = MainScreenWrapperReducer(initialState, action); + + //then + expect(rest).toEqual(initialState); + expect(subscriptionEnabled).toBe(payload.subscriptionEnabled); + expect(subscriptionPayload).toEqual(detail); + }); + }); + }); + + describe("getPersonalizationDetailsTests", () => { + describe('failure tests', () => { + beforeEach(async () => { + //given + fetch.mockRejectOnce(error); + await mockStore.dispatch(getPersonalizationDetails()); + }); + + it('action on request rejected by server test', () => { + //when + const [action, ...rest] = mockStore.getActions(); + + //then + expect(rest).toEqual([]); + expect(action.type).toBe(globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE); + expect(action.data.msgText).toEqual(PERSONALIZATION_FAILED_MESSAGE); + }); + + it('reducer on request rejected by server test', () => { + //given + const [action, ..._] = mockStore.getActions(); + + //when + const state = MainScreenWrapperReducer(initialState, action); + + //then + expect(state).toEqual(initialState); + }); + }); + + describe('success tests', () => { + const personalizationPayload = {topLeftHeader: 'Foo', htmlDocumentTitle: 'Bar'}; + + beforeEach(async () => { + //given + fetch.once(JSON.stringify(personalizationPayload)); + await mockStore.dispatch(getPersonalizationDetails()); + }); + + it('action on personalization payload found test', () => { + //when + const [action, ...rest] = mockStore.getActions(); + + //then + expect(rest).toEqual([]); + expect(action.type).toBe(personalizationActionTypes.PERSONALIZATION_PAYLOAD_FOUND); + }); + + it("Reducer on personalization payload found test", async () => { + //given + const [action, ..._] = mockStore.getActions(); + + //when + const { + aaiTopLeftPersonalizedHeader, + aaiPersonalizedHtmlDocumentTitle, + ...rest + } = MainScreenWrapperReducer(initialState, action); + + //then + expect(rest).toEqual(initialState); + expect(aaiTopLeftPersonalizedHeader).toEqual(personalizationPayload.topLeftHeader); + expect(aaiPersonalizedHtmlDocumentTitle).toEqual(personalizationPayload.htmlDocumentTitle); + }); + }); + }); +}); diff --git a/test/app/configurableViews/ConfigurableViewActions.test.js b/test/app/configurableViews/ConfigurableViewActions.test.js new file mode 100644 index 0000000..9d7bc9e --- /dev/null +++ b/test/app/configurableViews/ConfigurableViewActions.test.js @@ -0,0 +1,208 @@ +import configureStore from 'redux-mock-store'; +import thunk from 'redux-thunk' +import fetchMock from 'fetch-mock'; +import { + configurableViewsActionTypes +} from 'app/configurableViews/ConfigurableViewConstants.js'; +import { + newCustomComponentsEvent, + setCustomRoutes, + getConfigurableViewConfigs +} from 'app/configurableViews/ConfigurableViewActions.js' + + +describe('ConfigurableViewActionTests', () => { + const sampleConfig = { + "id": "aggregateReport", + "title": "Aggregate Report", + "iconURL": "resources/images/sampleAggReportIcon.svg", + "iconHoverURL": "resources/images/sampleAggReportIconHover.svg", + "viewType": "ConfigurableCardView", + "layout": { + "draggable": true, + "resizable": true, + "rowHeight": 100, + "cardMargin": [ + 20, + 20 + ], + "cardPadding": [ + 20, + 20 + ], + "breakpoints": [ + { + "id": "lg", + "col": 12, + "width": 1400 + }, + { + "id": "md", + "col": 8, + "width": 1200 + }, + { + "id": "sm", + "col": 6, + "width": 1024 + } + ] + }, + "components": [ + { + "id": "visualization1", + "title": "Total VNFs", + "queryData": { + "eventId": "visualization1", + "api": "/get-component-data", + "method": "POST", + "headers": { + "accept": "application/json" + }, + "componentDataDescriptor": { + "index": "aggregate_generic-vnf_index", + "queryType": "aggregation", + "query": { + "filter": {}, + "queries": [], + "aggregations": [ + { + "name": "prov-status", + "aggregation": { + "group-by": { + "field": "prov-status", + "size": 0 + } + } + }, + { + "name": "orchestration-status", + "aggregation": { + "group-by": { + "field": "orchestration-status", + "size": 0 + } + } + }, + { + "name": "nf-type", + "aggregation": { + "group-by": { + "field": "nf-type", + "size": 0 + } + } + }, + { + "name": "nf-role", + "aggregation": { + "group-by": { + "field": "nf-role", + "size": 0 + } + } + } + ] + }, + "responseTransformation": { + "type": "count", + "spec": { + "countType": "total", + "countResponseLabel": "display" + } + } + } + }, + "containerData": { + "containerType": "NetworkQueryCard", + "visualizationType": "text", + "visualizationProp": { + "display": "", + "style": { + "textAlign": "center", + "fontSize": "50px", + "fontWeight": "bold", + "paddingTop": "50px" + } + }, + "breakpoints": { + "lg": { + "w": 2, + "h": 2, + "x": 0, + "y": 0 + }, + "md": { + "w": 2, + "h": 2, + "x": 0, + "y": 0 + }, + "sm": { + "w": 6, + "h": 2, + "x": 0, + "y": 0 + } + } + } + } + ] + }; + + it('newCustomComponentsEvent', () => { + const components = [ + { + compId: 'someId', + compName: 'Some Name' + } + ]; + const middlewares = [thunk]; + const mockStore = configureStore(middlewares); + const store = mockStore({}); + store.dispatch(newCustomComponentsEvent(components)); + const actions = store.getActions(); + expect(actions).toEqual([{ + type: configurableViewsActionTypes.CUSTOM_COMPONENTS_RECEIVED, + data: components + }]); + }); + + it('setCustomRoutes', () => { + const routes = [ + { + routeName: 'Some Custom Route', + path: 'some/route/path' + } + ]; + const middlewares = [thunk]; + const mockStore = configureStore(middlewares); + const store = mockStore({}); + store.dispatch(setCustomRoutes(routes)); + const actions = store.getActions(); + expect(actions).toEqual([{ + type: configurableViewsActionTypes.CUSTOM_ROUTES, + data: routes + }]); + }); + + it('getConfigurableViewConfigs', () => { + const middlewares = [thunk]; + const mockStore = configureStore(middlewares); + const store = mockStore({}); + const expectedActions = [ + { + type: configurableViewsActionTypes.CONFIGURABLE_VIEWS_CONFIG_RECEIVED, + data: sampleConfig + } + ]; + fetchMock.mock('*', sampleConfig); + + return store.dispatch(getConfigurableViewConfigs()) + .then( () => { + const actions = store.getActions(); + expect(actions).toEqual(expectedActions); + fetchMock.restore(); + }); + }); +}) diff --git a/test/app/configurableViews/ConfigurableViewReducer.test.js b/test/app/configurableViews/ConfigurableViewReducer.test.js new file mode 100644 index 0000000..0c5c46e --- /dev/null +++ b/test/app/configurableViews/ConfigurableViewReducer.test.js @@ -0,0 +1,54 @@ +import { + configurableViewsActionTypes +} from 'app/configurableViews/ConfigurableViewConstants.js'; +import ConfigurableViewReducer from 'app/configurableViews/ConfigurableViewReducer.js' +describe('ConfigurableViewsReducerTests', () => { + it('Action Type: CONFIGURABLE_VIEWS_CONFIG_RECEIVED', () => { + const data = { + viewId: 'someViewId', + viewName: 'Some View Name', + viewRoute: 'some/view/route' + }; + const action = { + type: configurableViewsActionTypes.CONFIGURABLE_VIEWS_CONFIG_RECEIVED, + data: data + }; + let state = {}; + state = ConfigurableViewReducer(state, action); + expect(state).toEqual({ + configurableViewsConfig: data + }); + }); + + it('Action Type: CUSTOM_COMPONENTS_RECEIVED', () => { + const data = { + componentName: 'someComponentName', + componentData: { + blah: 'blah', + filler: 'filler' + } + }; + const action = { + type: configurableViewsActionTypes.CUSTOM_COMPONENTS_RECEIVED, + data: data + }; + let state = {}; + state = ConfigurableViewReducer(state, action); + expect(state).toEqual({ + customComponents: data + }); + }); + + it('Action Type: CUSTOM_ROUTES', () => { + const data = 'some/custom/route'; + const action = { + type: configurableViewsActionTypes.CUSTOM_ROUTES, + data: data + }; + let state = {}; + state = ConfigurableViewReducer(state, action); + expect(state).toEqual({ + customRoutes: data + }); + }); +}) diff --git a/test/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBar.test.js b/test/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBar.test.js new file mode 100644 index 0000000..25676b7 --- /dev/null +++ b/test/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBar.test.js @@ -0,0 +1,35 @@ +import React from 'react'; +import { mount } from 'enzyme'; +import {Provider} from 'react-redux' +import configureStore from 'redux-mock-store'; + +import GlobalAutoCompleteSearchBar from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBar.jsx' +import AutoCompleteSearchBar from 'generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.jsx'; +import { + globalAutoCompleteSearchBarActionTypes +} from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants.js'; + +describe('GlobalAutoCompleteSearchBarTests', () => { + const initValue = 'some random search text'; + const initialState = { + globalAutoCompleteSearchBarReducer: { + value: initValue + } + }; + const mockStore = configureStore(); + let store, wrapper; + + beforeEach( () => { + store = mockStore(initialState); + wrapper = mount(); + }) + + it('render search bar - visible', () => { + expect(wrapper).toHaveLength(1); // ensure the message bar is mounted + expect(wrapper.find(AutoCompleteSearchBar)).toHaveLength(1); // ensure the InlineMessage is mounted + }); + + it('props assigned properly', () => { + expect(wrapper.find(AutoCompleteSearchBar).props().value).toEqual(initValue); // check that the props match + }) +}) diff --git a/test/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.test.js b/test/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.test.js new file mode 100644 index 0000000..1078df6 --- /dev/null +++ b/test/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.test.js @@ -0,0 +1,154 @@ +import i18n from 'utils/i18n/i18n'; +import GlobalAutoCompleteSearchBarReducer from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.js'; +import { + globalAutoCompleteSearchBarActionTypes, + NO_MATCHES_FOUND +} from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants.js'; +import { + MESSAGE_LEVEL_WARNING, + MESSAGE_LEVEL_DANGER +} from 'utils/GlobalConstants.js'; + +describe('GlobalAutoCompleteSearchBarReducerTests', () => { + it('Action Type: SUGGESTION_FOUND', () => { + const suggestions = [ + { + entityType: 'some entity type', + value: 'selected value' + }, + { + entityType: 'some entity type', + value: 'other selected value' + } + ]; + const errMsg = 'some error message'; + const action = { + type: globalAutoCompleteSearchBarActionTypes.SUGGESTION_FOUND, + data: { + suggestions: suggestions, + errorMsg: errMsg + } + }; + let state = {}; + state = GlobalAutoCompleteSearchBarReducer(state, action); + expect(state).toEqual({ + suggestions: suggestions, + cachedSuggestions: suggestions, + feedbackMsgText: errMsg, + feedbackMsgSeverity: MESSAGE_LEVEL_DANGER + }); + }); + + it('Action Type: SUGGESTION_NOT_FOUND', () => { + const action = { + type: globalAutoCompleteSearchBarActionTypes.SUGGESTION_NOT_FOUND, + }; + let state = {}; + state = GlobalAutoCompleteSearchBarReducer(state, action); + expect(state).toEqual({ + suggestions: [{ text: i18n(NO_MATCHES_FOUND)}], + cachedSuggestions: [{ entityType: i18n(NO_MATCHES_FOUND)}], + feedbackMsgText: '', + feedbackMsgSeverity: '' + }); + }); + + it('Action Type: CLEAR_SUGGESTIONS_TEXT_FIELD', () => { + const action = { + type: globalAutoCompleteSearchBarActionTypes.CLEAR_SUGGESTIONS_TEXT_FIELD, + }; + let state = {}; + state = GlobalAutoCompleteSearchBarReducer(state, action); + expect(state).toEqual({ + suggestions: [], + cachedSuggestions: [], + value: '', + feedbackMsgText: '', + feedbackMsgSeverity: '', + clearSearchText: false + }); + }); + + it('Action Type: CLEAR_SUGGESTIONS', () => { + const action = { + type: globalAutoCompleteSearchBarActionTypes.CLEAR_SUGGESTIONS, + }; + let state = {}; + state = GlobalAutoCompleteSearchBarReducer(state, action); + expect(state).toEqual({ + suggestions: [] + }); + }); + + it('Action Type: SUGGESTION_CHANGED', () => { + const suggestionText = 'some suggestion text'; + const action = { + type: globalAutoCompleteSearchBarActionTypes.SUGGESTION_CHANGED, + data: suggestionText + }; + let state = {}; + state = GlobalAutoCompleteSearchBarReducer(state, action); + expect(state).toEqual({ + value: suggestionText, + feedbackMsgText: '', + feedbackMsgSeverity: '' + }); + }); + + it('Action Type: SUGGESTION_CLICKED', () => { + const suggestion = { + entityType: 'some entity type', + value: 'selected value' + }; + const action = { + type: globalAutoCompleteSearchBarActionTypes.SUGGESTION_CLICKED, + data: { + selectedSuggestion: suggestion + } + }; + let state = {}; + state = GlobalAutoCompleteSearchBarReducer(state, action); + expect(state).toEqual({ + selectedSuggestion: suggestion, + performPrepareVisualization: true, + feedbackMsgText: '', + feedbackMsgSeverity: '' + }); + }); + + it('Action Type: NETWORK_ERROR', () => { + const errMsg = 'some error message'; + const action = { + type: globalAutoCompleteSearchBarActionTypes.NETWORK_ERROR, + data: { + errorMsg: errMsg + } + }; + let state = {}; + state = GlobalAutoCompleteSearchBarReducer(state, action); + expect(state).toEqual({ + suggestions: [], + cachedSuggestions: [], + feedbackMsgText: errMsg, + feedbackMsgSeverity: MESSAGE_LEVEL_DANGER + }); + }); + + it('Action Type: SEARCH_WARNING_EVENT', () => { + const errMsg = 'some error message'; + const action = { + type: globalAutoCompleteSearchBarActionTypes.SEARCH_WARNING_EVENT, + data: { + errorMsg: errMsg + } + }; + let state = {}; + state = GlobalAutoCompleteSearchBarReducer(state, action); + expect(state).toEqual({ + suggestions: [], + cachedSuggestions: [], + feedbackMsgText: errMsg, + feedbackMsgSeverity: MESSAGE_LEVEL_WARNING + }); + }); +}) diff --git a/test/app/globalInlineMessageBar/GlobalInlineMessageBar.test.js b/test/app/globalInlineMessageBar/GlobalInlineMessageBar.test.js new file mode 100644 index 0000000..9dc2a28 --- /dev/null +++ b/test/app/globalInlineMessageBar/GlobalInlineMessageBar.test.js @@ -0,0 +1,37 @@ +import React from 'react'; +import { mount } from 'enzyme'; +import {Provider} from 'react-redux' +import configureStore from 'redux-mock-store'; + +import GlobalInlineMessageBar from 'app/globalInlineMessageBar/GlobalInlineMessageBar.jsx' +import { + MESSAGE_LEVEL_WARNING +} from 'utils/GlobalConstants.js' +import InlineMessage from 'generic-components/InlineMessage/InlineMessage.jsx'; + +describe('GlobalInlineMessageBarTests', () => { + const errMsg = 'some random message'; + const initialState = { + globalInlineMessageBar: { + feedbackMsgText: errMsg, + feedbackMsgSeverity: MESSAGE_LEVEL_WARNING + } + }; + const mockStore = configureStore(); + let store, wrapper; + + beforeEach( () => { + store = mockStore(initialState); + wrapper = mount(); + }) + + it('render message bar - visible', () => { + expect(wrapper).toHaveLength(1); // ensure the message bar is mounted + expect(wrapper.find(InlineMessage)).toHaveLength(1); // ensure the InlineMessage is mounted + }); + + it('props assigned properly', () => { + expect(wrapper.find(InlineMessage).props().level).toEqual(MESSAGE_LEVEL_WARNING); // check that the props match + expect(wrapper.find(InlineMessage).props().messageTxt).toEqual(errMsg); // check that the props match + }) +}) diff --git a/test/app/globalInlineMessageBar/GlobalInlineMessageBarAction.test.js b/test/app/globalInlineMessageBar/GlobalInlineMessageBarAction.test.js new file mode 100644 index 0000000..4def5ac --- /dev/null +++ b/test/app/globalInlineMessageBar/GlobalInlineMessageBarAction.test.js @@ -0,0 +1,42 @@ +import configureStore from 'redux-mock-store'; +import thunk from 'redux-thunk'; + +import { + getSetGlobalMessageEvent, + getClearGlobalMessageEvent +} from 'app/globalInlineMessageBar/GlobalInlineMessageBarActions.js'; +import { + globalInlineMessageBarActionTypes +} from 'app/globalInlineMessageBar/GlobalInlineMessageBarConstants.js'; +import { + MESSAGE_LEVEL_WARNING +} from 'utils/GlobalConstants.js' + +describe('GlobalInlineMessageBarActionTests', () => { + it('getSetGlobalMessageEvent', () => { + const middlewares = [thunk]; + const mockStore = configureStore(middlewares); + const store = mockStore({}); + const msgText = 'some test msg'; + store.dispatch(getSetGlobalMessageEvent(msgText, MESSAGE_LEVEL_WARNING)); + const actions = store.getActions(); + expect(actions).toEqual([{ + type: globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE, + data: { + msgText: msgText, + msgSeverity: MESSAGE_LEVEL_WARNING + } + }]); + }); + + it('getClearGlobalMessageEvent', () => { + const middlewares = [thunk]; + const mockStore = configureStore(middlewares); + const store = mockStore({}); + store.dispatch(getClearGlobalMessageEvent()); + const actions = store.getActions(); + expect(actions).toEqual([{ + type: globalInlineMessageBarActionTypes.CLEAR_GLOBAL_MESSAGE + }]); + }); +}) diff --git a/test/app/globalInlineMessageBar/GlobalInlineMessageBarReducer.test.js b/test/app/globalInlineMessageBar/GlobalInlineMessageBarReducer.test.js new file mode 100644 index 0000000..62389b4 --- /dev/null +++ b/test/app/globalInlineMessageBar/GlobalInlineMessageBarReducer.test.js @@ -0,0 +1,40 @@ +import GlobalInlineMessageBarReducer from 'app/globalInlineMessageBar/GlobalInlineMessageBarReducer.js'; +import { + globalInlineMessageBarActionTypes +} from 'app/globalInlineMessageBar/GlobalInlineMessageBarConstants.js'; +import { + MESSAGE_LEVEL_WARNING +} from 'utils/GlobalConstants.js' + +describe('GlobalInlineMessageBarReducerTests', () => { + it('Action Type: SET_GLOBAL_MESSAGE', () => { + const action = { + type: globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE, + data: { + msgText: 'some error message here', + msgSeverity: MESSAGE_LEVEL_WARNING + } + }; + let state = {}; + state = GlobalInlineMessageBarReducer(state, action); + expect(state).toEqual({ + feedbackMsgText: action.data.msgText, + feedbackMsgSeverity: action.data.msgSeverity + }); + }); + + it('Action Type: CLEAR_GLOBAL_MESSAGE', () => { + const action = { + type: globalInlineMessageBarActionTypes.CLEAR_GLOBAL_MESSAGE + }; + let state = { + feedbackMsgText: 'some error message here', + feedbackMsgSeverity: MESSAGE_LEVEL_WARNING + }; + state = GlobalInlineMessageBarReducer(state, action); + expect(state).toEqual({ + feedbackMsgText: '', + feedbackMsgSeverity: '' + }); + }); +}) diff --git a/test/app/networking/NetworkCalls.test.js b/test/app/networking/NetworkCalls.test.js new file mode 100644 index 0000000..373fbac --- /dev/null +++ b/test/app/networking/NetworkCalls.test.js @@ -0,0 +1,124 @@ +import NetworkCalls from 'app/networking/NetworkCalls'; +import * as sinon from "sinon"; + +describe("Network Utils", () => { + + let suite; + + beforeEach(() => { + suite = {}; + suite.sandbox = sinon.createSandbox(); + }); + + afterEach(() => { + suite.sandbox.reset(); + }); + + describe('#fetchRequest', () => { + it('should fetch request', () => { + global.fetch = suite.sandbox.stub(); + + const then = suite.sandbox.stub(); + + fetch.returns({then}); + + NetworkCalls.fetchRequest("URL", "POST", "POST", "HEADER", "BODY"); + sinon.assert.calledOnce(then); + + expect(then.firstCall.args[0]({json: () => "json"})).toEqual("json"); + sinon.assert.calledOnce(fetch); + }); + }); + + describe('#fetchConfigurableViewRequest', () => { + it('fetch configurable request', () => { + const queryData = { + api: "api", + method: "method", + headers: "headers", + componentDataDescriptor: {object: "object"} + }; + + const fetchPromise = Promise.resolve(); + global.fetch = suite.sandbox.stub(); + + global.fetch + .withArgs(queryData.api, { + method: queryData.method, + headers: queryData.headers, + body: queryData.body + }) + .returns(fetchPromise); + + NetworkCalls.fetchConfigurableViewRequest(queryData); + + sinon.assert.calledWith(fetch, "http://localhost:api", { + method: queryData.method, + headers: queryData.headers, + credentials: "same-origin", + body: '{"object":"object"}' + }); + }); + }); + + describe('#fetchRequestObj', () => { + it('fetch request object', () => { + + const fetchPromise = Promise.resolve(); + global.fetch = suite.sandbox.stub(); + const url = 'url'; + + global.fetch + .withArgs(url, { + method: 'GET', + headers: 'POST_HEADER', + body: 'BODY' + + }) + .returns(fetchPromise); + + NetworkCalls.fetchRequestObj(url, "GET", "POST_HEADER", "BODY"); + + sinon.assert.calledWith(fetch, url, { + credentials: 'same-origin', + method: "GET", + headers: "POST_HEADER", + body: "BODY" + }); + }); + }); + + describe('#getRequest', () => { + it("should fetch any request", () => { + const json = suite.sandbox.stub(); + const fetchPromise = Promise.resolve({json}); + global.fetch = suite.sandbox.stub(); + + global.fetch + .withArgs('URL', { + credentials: 'same-origin', + method: 'GET' + }) + .returns(fetchPromise); + + NetworkCalls.getRequest("URL", "GET"); + + return fetchPromise.then(() => { + sinon.assert.calledOnce(json); + }); + }); + }); + + describe('#genericRequest', () => { + it('should fetch any generic request', () => { + global.fetch = suite.sandbox.stub(); + const then = suite.sandbox.stub(); + fetch.returns({then}); + NetworkCalls.genericRequest("localhost", "/relativeUrl", "GET"); + + expect(then.firstCall.args[0]({json: () => "d"})).toEqual("d"); + + sinon.assert.calledOnce(fetch); + }); + }); +}); diff --git a/test/app/networking/NetworkUtil.test.js b/test/app/networking/NetworkUtil.test.js new file mode 100644 index 0000000..1743813 --- /dev/null +++ b/test/app/networking/NetworkUtil.test.js @@ -0,0 +1,22 @@ +import {getTSUIElasticSearchQueryString} from 'app/networking/NetworkUtil'; + +describe("Network Utils", () => { + describe('#getTSUIElasticSearchQueryString', () => { + it('should return query body', () => { + const query = "query"; + const response = getTSUIElasticSearchQueryString(query); + expect(response).toEqual({"maxResults": "10", "queryStr": "query"}); + }); + + it('should return partial request query', () => { + const query = ""; + const response = getTSUIElasticSearchQueryString(query); + expect(response).toEqual({"maxResults": "10", "queryStr": ""}); + }); + + it('should be truthy', () => { + const query = ""; + expect(getTSUIElasticSearchQueryString(query)).toBeTruthy(); + }) + }); +}); diff --git a/test/app/tierSupport/SelectedNodeDetails.test.js b/test/app/tierSupport/SelectedNodeDetails.test.js new file mode 100644 index 0000000..5f97626 --- /dev/null +++ b/test/app/tierSupport/SelectedNodeDetails.test.js @@ -0,0 +1,141 @@ +import React from 'react'; +import { shallow, mount } from 'enzyme'; +import {Provider} from 'react-redux' +import configureStore from 'redux-mock-store'; +import Table from 'react-bootstrap/lib/Table'; + +import ConnectedSelectedNodeDetails, { SelectedNodeDetails } from 'app/tierSupport/selectedNodeDetails/SelectedNodeDetails.jsx'; +import { SELECTED_NODE_TABLE_COLUMN_NAMES } from 'app/tierSupport/selectedNodeDetails/SelectedNodeDetailsConstants.js'; +import LaunchInContext from 'app/tierSupport/launchExternalResource/LaunchExternalResource.jsx'; + +describe('SelectedNodeDetails - Shallow render of component', () => { + let wrapper; + const nodeTypeProp = 'VNF'; + const uidProp = 'SomeValidUIDName'; + const nodeDataProp = { + 'interface-role': 'MPLS', + 'in-maint': 'false', + 'interface-type': 'WAN', + 'port-description': 'MPLS port on 10_NSG16_location4', + 'resource-version': '123456789', + 'interface-name': '10_port1_location4', + 'uri': 'network/pnfs/pnf/10_NSG14_location4/p-interfaces/p-interface/10_port1_location4' + }; + + beforeEach( () => { + wrapper = shallow( + ); + }) + + it('Render basic component', () => { + expect(wrapper.length).toEqual(1); + }); + + it('Verify node type is displayed as a header', () => { + expect(wrapper.contains(

    {nodeTypeProp}

    )).toBe(true); + expect(wrapper.find('h2')).toHaveLength(1); + }); + + it('Verify uid is displayed', () => { + expect(wrapper.contains({uidProp} )).toBe(true); + }); + + it('Verify node data table is displayed', () => { + // verify table has a row for each node data prop plus one row for the column headers + expect(wrapper.find(Table)).toHaveLength(1); + expect(wrapper.find(Table).props().bsClass).toEqual('ts-selected-node-table'); + expect(wrapper.find(Table).children()).toHaveLength(2); // thead and tbody + + // validate the table header content + expect(wrapper.find('thead')).toHaveLength(1); + let cellClassName; + for (let index = 1; index <= SELECTED_NODE_TABLE_COLUMN_NAMES.length; index++) { + cellClassName = (index % 2 ? 'left-column-cell' : 'right-column-cell'); + expect(wrapper.contains( + {SELECTED_NODE_TABLE_COLUMN_NAMES[index-1]} + )).toBe(true); + } + + // validate the table body content + expect(wrapper.find('tbody')).toHaveLength(1); + expect(wrapper.find('tbody').children()).toHaveLength(7); // 1 row for each of the 7 properties + for (let prop in nodeDataProp) { + expect(wrapper.contains( + {prop} + )).toBe(true); + expect(wrapper.contains( + {nodeDataProp[prop]} + )).toBe(true); + } + }); +}) + +describe('SelectedNodeDetails - Shallow render of component with no node data', () => { + let wrapper; + const nodeTypeProp = 'VNF'; + const uidProp = 'SomeValidUIDName'; + const nodeDataProp = {}; + + beforeEach( () => { + wrapper = shallow( + ); + }) + + it('Render basic component', () => { + expect(wrapper.length).toEqual(1); + }); + + it('Verify node data table is hidden', () => { + // verify table is hidden + expect(wrapper.find(Table)).toHaveLength(1); + expect(wrapper.find(Table).props().bsClass).toEqual('hidden'); + }); +}) + +describe('SelectedNodeDetails - Render React Component (wrapped in )', () => { + const initialState = { + tierSupport: { + launchExternalResourceReducer: { + externalResourcePayload: {} + }, + selectedNodeDetails: { + nodeType: 'VNF', + uid: 'AAI/CLYMR/000509/SD_WAN', + nodeData: { + 'interface-role': 'MPLS', + 'in-maint': 'false', + 'interface-type': 'WAN', + 'port-description': 'MPLS port on 10_NSG16_location4', + 'resource-version': '123456789', + 'interface-name': '10_port1_location4', + 'uri': 'network/pnfs/pnf/10_NSG14_location4/p-interfaces/p-interface/10_port1_location4' + } + } + } + }; + const mockStore = configureStore(); + let store, wrapper; + + beforeEach( () => { + store = mockStore(initialState); + wrapper = mount(); + }) + + it('Render the connected component', () => { + expect(wrapper.find(ConnectedSelectedNodeDetails).length).toEqual(1); + }); + + it('Validate props from store', () => { + expect(wrapper.find(SelectedNodeDetails).props().uid).toEqual(initialState.tierSupport.selectedNodeDetails.uid); + expect(wrapper.find(SelectedNodeDetails).props().nodeType).toEqual(initialState.tierSupport.selectedNodeDetails.nodeType); + expect(wrapper.find(SelectedNodeDetails).props().nodeData).toEqual(initialState.tierSupport.selectedNodeDetails.nodeData); + }); +}) diff --git a/test/app/tierSupport/SelectedNodeDetailsReducer.test.js b/test/app/tierSupport/SelectedNodeDetailsReducer.test.js new file mode 100644 index 0000000..238d21c --- /dev/null +++ b/test/app/tierSupport/SelectedNodeDetailsReducer.test.js @@ -0,0 +1,248 @@ +import SelectedNodeDetailsReducer from 'app/tierSupport/selectedNodeDetails/SelectedNodeDetailsReducer.js'; +import {tierSupportActionTypes} from 'app/tierSupport/TierSupportConstants.js'; +import { + globalAutoCompleteSearchBarActionTypes +} from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants.js'; + +describe('SelectedNodeDetails - Reducer Tests', () => { + it('Action Type: TS_NODE_SEARCH_RESULTS', () => { + const action = { + type: tierSupportActionTypes.TS_NODE_SEARCH_RESULTS, + data: { + nodes: [ + { + 'id': 'AAI/CLYMR/000509/SD_WAN', + 'itemType': 'service-instance', + 'itemNameKey': 'service-instance.AAI/SPRKY/000509/SD_WAN', + 'itemNameValue': 'AAI/SPRKY/000509/SD_WAN', + 'itemProperties': { + 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN', + 'resource-version':'1508078039815' + }, + 'itemIntegrity' : { + 'entityId' : 'AEEhny_vnf1_under_fw-si1', + 'entityType' : 'vnf', + 'entityLink' : 'cloud-infrastr084-1377-4f49-9c72-f0_location2', + 'initialTimestamp' :'2017-11-13T16:58:01Z', + 'latestValidationTimestamp':'2017-11-13T16:58:01Z', + 'resourceVersion':'1510592264096', + 'violations': [] + }, + 'nodeMeta': { + 'className': 'selectedSearchedNodeClass', + 'nodeDebug': null, + 'selfLinkResponseTimeInMs': 628, + 'relationshipNode': false, + 'searchTarget': true, + 'enrichableNode': false, + 'nodeValidated': true, + 'nodeIssue': false, + 'maxAltitude': 4, + 'nodeType': 'serviceInstance', + 'nodeLabel1':'service-instance', + 'nodeLabel2':'AAI/SPRKY/000509/SD_WAN' + }, + 'rootNode' : false + } + ] + } + }; + let state = { + nodeType: '', + uid: '', + nodeData: {} + }; + state = SelectedNodeDetailsReducer(state, action); + expect(state).toEqual({ + nodeType: action['data']['nodes'][0]['itemType'], + uid: action['data']['nodes'][0]['itemNameValue'], + nodeData: action['data']['nodes'][0]['itemProperties'] + }); + }); + + it('Action Type: TS_NODE_SEARCH_RESULTS - searchTarget === false', () => { + const action = { + type: tierSupportActionTypes.TS_NODE_SEARCH_RESULTS, + data: { + nodes: [ + { + 'id': 'AAI/CLYMR/000509/SD_WAN', + 'itemType': 'service-instance', + 'itemNameKey': 'service-instance.AAI/SPRKY/000509/SD_WAN', + 'itemNameValue': 'AAI/SPRKY/000509/SD_WAN', + 'itemProperties': { + 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN', + 'resource-version':'1508078039815' + }, + 'itemIntegrity' : { + 'entityId' : 'AEEhny_vnf1_under_fw-si1', + 'entityType' : 'vnf', + 'entityLink' : 'cloud-infrastr084-1377-4f49-9c72-f0_location2', + 'initialTimestamp' :'2017-11-13T16:58:01Z', + 'latestValidationTimestamp':'2017-11-13T16:58:01Z', + 'resourceVersion':'1510592264096', + 'violations': [] + }, + 'nodeMeta': { + 'className': 'selectedSearchedNodeClass', + 'nodeDebug': null, + 'selfLinkResponseTimeInMs': 628, + 'relationshipNode': false, + 'searchTarget': false, + 'enrichableNode': false, + 'nodeValidated': true, + 'nodeIssue': false, + 'maxAltitude': 4, + 'nodeType': 'serviceInstance', + 'nodeLabel1':'service-instance', + 'nodeLabel2':'AAI/SPRKY/000509/SD_WAN' + }, + 'rootNode' : false + } + ] + } + }; + let state = { + nodeType: 'Complex', + uid: 'ABC', + nodeData: { + 'service-instance-id': 'blah/blah/blah', + 'resource-version':'123456' + } + }; + state = SelectedNodeDetailsReducer(state, action); + expect(state).toEqual({ + nodeType: '', + uid: '', + nodeData: {} + }); + }); + + it('Action Type: TS_GRAPH_NODE_SELECTED', () => { + const action = { + type: tierSupportActionTypes.TS_GRAPH_NODE_SELECTED, + data: { + itemProperties: { + 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN', + 'resource-version':'1508078039815' + }, + itemType: 'Complex', + itemNameValue: '123456' + } + }; + let state = { + nodeType: '', + uid: '', + nodeData: {} + }; + state = SelectedNodeDetailsReducer(state, action); + expect(state).toEqual({ + nodeType: action['data']['itemType'], + uid: action['data']['itemNameValue'], + nodeData: action['data']['itemProperties'] + }); + }); + + it('Action Type: TIER_SUPPORT_NETWORK_ERROR', () => { + const action = { + type: tierSupportActionTypes.TIER_SUPPORT_NETWORK_ERROR, + }; + let state = { + nodeType: 'Complex', + uid: '12345', + nodeData: { + 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN', + 'resource-version':'1508078039815' + } + }; + state = SelectedNodeDetailsReducer(state, action); + expect(state).toEqual({ + nodeType: '', + uid: '', + nodeData: {} + }); + }); + + it('Action Type: TIER_SUPPORT_CLEAR_DATA', () => { + const action = { + type: tierSupportActionTypes.TIER_SUPPORT_CLEAR_DATA, + }; + let state = { + nodeType: 'Complex', + uid: '12345', + nodeData: { + 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN', + 'resource-version':'1508078039815' + } + }; + state = SelectedNodeDetailsReducer(state, action); + expect(state).toEqual({ + nodeType: '', + uid: '', + nodeData: {} + }); + }); + + it('Action Type: TS_NODE_SEARCH_NO_RESULTS', () => { + const action = { + type: tierSupportActionTypes.TS_NODE_SEARCH_NO_RESULTS, + }; + let state = { + nodeType: 'Complex', + uid: '12345', + nodeData: { + 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN', + 'resource-version':'1508078039815' + } + }; + state = SelectedNodeDetailsReducer(state, action); + expect(state).toEqual({ + nodeType: '', + uid: '', + nodeData: {} + }); + }); + + it('Action Type: SEARCH_WARNING_EVENT', () => { + const action = { + type: globalAutoCompleteSearchBarActionTypes.SEARCH_WARNING_EVENT, + }; + let state = { + nodeType: 'Complex', + uid: '12345', + nodeData: { + 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN', + 'resource-version':'1508078039815' + } + }; + state = SelectedNodeDetailsReducer(state, action); + expect(state).toEqual({ + nodeType: '', + uid: '', + nodeData: {} + }); + }); + + it('Invalid Action Type', () => { + const action = { + type: 'Nonexistent Action Type', + }; + let state = { + nodeType: 'Complex', + uid: '12345', + nodeData: { + 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN', + 'resource-version':'1508078039815' + } + }; + state = SelectedNodeDetailsReducer(state, action); + expect(state).toEqual({ + nodeType: 'Complex', + uid: '12345', + nodeData: { + 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN', + 'resource-version':'1508078039815' + } + }); + }); +}) diff --git a/test/app/tierSupport/TierSupportActions.test.js b/test/app/tierSupport/TierSupportActions.test.js new file mode 100644 index 0000000..62485ee --- /dev/null +++ b/test/app/tierSupport/TierSupportActions.test.js @@ -0,0 +1,177 @@ +import configureStore from 'redux-mock-store'; +import thunk from 'redux-thunk' +import { + onNodeDetailsChange, + splitPaneResize, + onNodeMenuChange, + clearVIData, + setNotificationText +} from 'app/tierSupport/TierSupportActions.js'; +import { + tierSupportActionTypes +} from 'app/tierSupport/TierSupportConstants.js'; +import { + MESSAGE_LEVEL_WARNING +} from 'utils/GlobalConstants.js'; +import { + globalInlineMessageBarActionTypes +} from 'app/globalInlineMessageBar/GlobalInlineMessageBarConstants.js'; + +describe('TierSupportActionTests', () => { + it('onNodeDetailsChange', () => { + const newDetails = { + id: '7352312c7bfa814c3071a803d98c5b670952765974876e55ef954e0f8a930b1c', + itemType: 'complex', + nodeMeta: { + nodeLabel1: 'Artic', + nodeValidated: false, + nodeLocation: 'bottom' + }, + rootNode: false, + index: 2, + }; + const middlewares = [thunk]; + const mockStore = configureStore(middlewares); + const store = mockStore({ tierSupportReducer: {} }); + store.dispatch(onNodeDetailsChange(newDetails)); + const actions = store.getActions(); + expect(actions).toEqual([{ + type: tierSupportActionTypes.TS_GRAPH_NODE_SELECTED, + data: newDetails + }]); + }); + + it('splitPaneResize', () => { + const initialLoad = { + test: 'message' + }; + const middlewares = [thunk]; + const mockStore = configureStore(middlewares); + const store = mockStore({ tierSupportReducer: {} }); + store.dispatch(splitPaneResize(initialLoad)); + const actions = store.getActions(); + expect(actions).toEqual([{ + type: tierSupportActionTypes.SPLIT_PANE_RESIZE, + data: initialLoad + }]); + }); + + it('onNodeMenuChange', () => { + const selectedMenu = { + test: 'menuData' + }; + const middlewares = [thunk]; + const mockStore = configureStore(middlewares); + const store = mockStore({ tierSupportReducer: {} }); + store.dispatch(onNodeMenuChange(selectedMenu)); + const actions = store.getActions(); + expect(actions).toEqual([{ + type: tierSupportActionTypes.TS_GRAPH_NODE_MENU_SELECTED, + data: selectedMenu + }]); + }); + + it('clearVIData', () => { + const middlewares = [thunk]; + const mockStore = configureStore(middlewares); + const store = mockStore({ tierSupportReducer: {} }); + store.dispatch(clearVIData()); + const actions = store.getActions(); + expect(actions).toEqual([{ + type: tierSupportActionTypes.TIER_SUPPORT_CLEAR_DATA + }]); + }); + // + // it('fetchSelectedNodeElement - no results', () => { + // const middlewares = [thunk]; + // const mockStore = configureStore(middlewares); + // const store = mockStore({ tierSupportReducer: {} }); + // const nodes = [ + // { + // id: '7352312c7bfa814c3071a803d98c5b670952765974876e55ef954e0f8a930b1c', + // itemType: 'complex', + // nodeMeta: { + // className: 'selectedSearchedNodeClass', + // nodeLabel1: 'Artic', + // nodeValidated: false, + // nodeLocation: 'bottom' + // }, + // rootNode: false, + // index: 2 + // }, + // { + // id: '3899453d98c5b670952765974876e55ef954e0f8a930b1c', + // itemType: 'generic-vnf', + // nodeMeta: { + // className: 'someOtherClassName', + // nodeLabel1: 'Artic', + // nodeValidated: false, + // nodeLocation: 'bottom' + // }, + // rootNode: false, + // index: 1 + // } + // ]; + // const expectedActions = [ + // { + // type: tierSupportActionTypes.TS_NODE_SEARCH_RESULTS, + // data: { + // nodes: nodes + // } + // }, + // { + // type: tierSupportActionTypes.TS_GRAPH_NODE_SELECTED, + // data: nodes[0] + // } + // ]; + // + // console.log(nodes); + // + // let fetchRequestCallback = () => { + // const results = { + // nodes: nodes + // }; + // let init = { status: 200 }; + // let myBlob = new Blob(); + // let response = new Response(); + // return new Promise((resolve, reject) => { + // resolve(response); + // }); + // }; + // return store.dispatch(fetchSelectedNodeElement(fetchRequestCallback)) + // .then( () => { + // const actions = store.getActions(); + // expect(actions).toEqual(expectedActions); + // }); + // }); + + it('setNotificationText', () => { + const middlewares = [thunk]; + const mockStore = configureStore(middlewares); + const store = mockStore({ tierSupportReducer: {} }); + const msgText = 'some test text'; + const msgSeverity = MESSAGE_LEVEL_WARNING; + store.dispatch(setNotificationText(msgText, msgSeverity)); + const actions = store.getActions(); + expect(actions).toEqual([{ + type: globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE, + data: { + msgText: msgText, + msgSeverity: msgSeverity + } + }]); + }); + + it('Clear notification text with setNotificationText', () => { + const middlewares = [thunk]; + const mockStore = configureStore(middlewares); + const store = mockStore({ tierSupportReducer: {} }); + const msgText = ''; + const msgSeverity = MESSAGE_LEVEL_WARNING; + store.dispatch(setNotificationText(msgText, msgSeverity)); + const actions = store.getActions(); + expect(actions).toEqual([{ + type: globalInlineMessageBarActionTypes.CLEAR_GLOBAL_MESSAGE + }]); + }); +}) diff --git a/test/app/tierSupport/TierSupportReducer.test.js b/test/app/tierSupport/TierSupportReducer.test.js new file mode 100644 index 0000000..9825a06 --- /dev/null +++ b/test/app/tierSupport/TierSupportReducer.test.js @@ -0,0 +1,206 @@ +import TierSupportReducer from 'app/tierSupport/TierSupportReducer.js'; +import ForceDirectedGraph from 'generic-components/graph/ForceDirectedGraph.jsx'; +import { + tierSupportActionTypes, + TSUI_GRAPH_MENU_NODE_DETAILS +} from 'app/tierSupport/TierSupportConstants.js'; +import { + MESSAGE_LEVEL_WARNING, + MESSAGE_LEVEL_DANGER +} from 'utils/GlobalConstants.js'; +import { + globalAutoCompleteSearchBarActionTypes +} from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants.js'; + +describe('TierSupportReducerTests', () => { + it('Action Type: TS_NODE_SEARCH_RESULTS', () => { + ForceDirectedGraph.graphCounter = 0; // ensuring counter is at zero after previous tests + const action = { + type: tierSupportActionTypes.TS_NODE_SEARCH_RESULTS, + data: { + nodes: [ + { + nodeMeta: { + searchTarget: true + }, + itemProperties: 'someProperty' + } + ], + links: ['link', 'information'], + graphMeta: { graph: 'meta' } + } + }; + let graphData = ForceDirectedGraph.generateNewProps(action.data.nodes, action.data.links, + action.data.graphMeta); + ForceDirectedGraph.graphCounter = 0; // ensuring counter is at zero after previous statement + let state = {}; + state = TierSupportReducer(state, action); + expect(state.tierSupportReducer).toEqual({ + forceDirectedGraphRawData: graphData, + feedbackMsgText: '', + feedbackMsgSeverity: '' + }); + }); + + it('Action Type: TS_GRAPH_NODE_MENU_SELECTED', () => { + const action = { + type: tierSupportActionTypes.TS_GRAPH_NODE_MENU_SELECTED, + data: { + attr1: 'someValue', + attr2: 'someOterValue' + } + }; + let state = {}; + state = TierSupportReducer(state, action); + expect(state.tierSupportReducer).toEqual({ + graphNodeSelectedMenu: action.data + }); + }); + + it('Action Type: TS_NODE_SEARCH_NO_RESULTS', () => { + ForceDirectedGraph.graphCounter = 0; // ensuring counter is at zero after previous tests + let emptyNodesAndLinksNoResults = { + graphCounter: 1, + graphMeta: {}, + linkDataArray: [], + nodeDataArray: [] + }; + const action = { + type: tierSupportActionTypes.TS_NODE_SEARCH_NO_RESULTS, + data: { + errorMsg: 'some error message' + } + }; + let state = {}; + state = TierSupportReducer(state, action); + expect(state.tierSupportReducer).toEqual({ + forceDirectedGraphRawData: emptyNodesAndLinksNoResults, + graphNodeSelectedMenu: TSUI_GRAPH_MENU_NODE_DETAILS, + feedbackMsgText: action.data.errorMsg, + feedbackMsgSeverity: MESSAGE_LEVEL_WARNING + }); + }); + + it('Action Type: TIER_SUPPORT_NETWORK_ERROR', () => { + ForceDirectedGraph.graphCounter = 0; // ensuring counter is at zero after previous tests + let emptyNodesAndLinksNoResults = { + graphCounter: 1, + graphMeta: {}, + linkDataArray: [], + nodeDataArray: [] + }; + const action = { + type: tierSupportActionTypes.TIER_SUPPORT_NETWORK_ERROR, + data: { + errorMsg: 'some error message' + } + }; + let state = {}; + state = TierSupportReducer(state, action); + expect(state.tierSupportReducer).toEqual({ + forceDirectedGraphRawData: emptyNodesAndLinksNoResults, + graphNodeSelectedMenu: TSUI_GRAPH_MENU_NODE_DETAILS, + feedbackMsgText: action.data.errorMsg, + feedbackMsgSeverity: MESSAGE_LEVEL_DANGER + }); + }); + + it('Action Type: TIER_SUPPORT_CLEAR_DATA', () => { + ForceDirectedGraph.graphCounter = 0; // ensuring counter is at zero after previous tests + let emptyNodesAndLinksNoResults = { + graphCounter: 1, + graphMeta: {}, + linkDataArray: [], + nodeDataArray: [] + }; + const action = { + type: tierSupportActionTypes.TIER_SUPPORT_CLEAR_DATA + }; + let state = {}; + state = TierSupportReducer(state, action); + expect(state.tierSupportReducer).toEqual({ + forceDirectedGraphRawData: emptyNodesAndLinksNoResults, + graphNodeSelectedMenu: TSUI_GRAPH_MENU_NODE_DETAILS, + feedbackMsgText: '', + feedbackMsgSeverity: '' + }); + }); + + it('Action Type: TS_GRAPH_NODE_SELECTED', () => { + const action = { + type: tierSupportActionTypes.TS_GRAPH_NODE_SELECTED, + data: 'some action data' + }; + let state = {}; + state = TierSupportReducer(state, action); + expect(state.tierSupportReducer).toEqual({ + nodeData: action.data + }); + }); + + it('Action Type: TIER_SUPPORT_ACTIVATE_BUSY_FEEDBACK', () => { + const action = { + type: tierSupportActionTypes.TIER_SUPPORT_ACTIVATE_BUSY_FEEDBACK, + }; + let state = {}; + state = TierSupportReducer(state, action); + expect(state.tierSupportReducer).toEqual({ + enableBusyFeedback: true + }); + }); + + it('Action Type: TIER_SUPPORT_DISABLE_BUSY_FEEDBACK', () => { + const action = { + type: tierSupportActionTypes.TIER_SUPPORT_DISABLE_BUSY_FEEDBACK, + }; + let state = {}; + state = TierSupportReducer(state, action); + expect(state.tierSupportReducer).toEqual({ + enableBusyFeedback: false + }); + }); + + it('Action Type: SEARCH_WARNING_EVENT', () => { + ForceDirectedGraph.graphCounter = 0; // ensuring counter is at zero after previous tests + let emptyNodesAndLinksNoResults = { + graphCounter: 1, + graphMeta: {}, + linkDataArray: [], + nodeDataArray: [] + }; + const action = { + type: globalAutoCompleteSearchBarActionTypes.SEARCH_WARNING_EVENT, + data: { + errorMsg: 'some warning msg' + } + }; + let state = {}; + state = TierSupportReducer(state, action); + expect(state.tierSupportReducer).toEqual({ + forceDirectedGraphRawData: emptyNodesAndLinksNoResults, + graphNodeSelectedMenu: TSUI_GRAPH_MENU_NODE_DETAILS + }); + }); + + it('Action Type: TS_OVERLAY_NETWORK_CALLBACK_RESPONSE_RECEIVED', () => { + const action = { + type: tierSupportActionTypes.TS_OVERLAY_NETWORK_CALLBACK_RESPONSE_RECEIVED, + data: { + curData: { + attr1: 'value1', + attr2: 'value2' + }, + paramName: 'attr2', + overlayData: 'someValue2' + } + }; + let state = {}; + state = TierSupportReducer(state, action); + expect(state.tierSupportReducer).toEqual({ + nodeData: { + attr1: 'value1', + attr2: 'someValue2' + } + }); + }); +}) diff --git a/test/app/vnfSearch/VnfSearch.test.js b/test/app/vnfSearch/VnfSearch.test.js new file mode 100644 index 0000000..3875543 --- /dev/null +++ b/test/app/vnfSearch/VnfSearch.test.js @@ -0,0 +1,49 @@ +import React from 'react'; +import { shallow, mount } from 'enzyme'; +import {Provider} from 'react-redux'; +import configureStore from 'redux-mock-store'; + +import ConnectedVnfSearch, { vnfSearch } from 'app/vnfSearch/VnfSearch.jsx'; + +describe('VnfSearch - Shallow render of component', () => { + let wrapper; + const vnfFilters = {}; + const vnfVisualizationPanelClass = 'collapsible-panel-main-panel'; + const unifiedFilterValues = {}; + + beforeEach( () => { + wrapper = shallow( + + ); + }) + + it('Render basic component', () => { + expect(wrapper.length).toEqual(1); + }); +}) +// +// describe('VnfSearch - Render React Component (wrapped in )', () => { +// const initialState = { +// vnfSearch: {} +// }; +// const mockStore = configureStore(); +// let store, wrapper; +// +// beforeEach( () => { +// store = mockStore(initialState); +// wrapper = mount(); +// }) +// +// it('Render the connected component', () => { +// expect(wrapper.find(ConnectedVnfSearch).length).toEqual(1); +// }); +// +// it('Validate props from store', () => { +// expect(wrapper.find(VnfSearchNfRoleVisualization).props().enableBusyFeedback).toEqual(initialState.vnfSearch.enableBusyFeedback); +// expect(wrapper.find(VnfSearchNfRoleVisualization).props().processedNfRoleCountChartData).toEqual(initialState.vnfSearch.processedNfRoleCountChartData); +// }); +// }) diff --git a/test/app/vnfSearch/VnfSearchActions.test.js b/test/app/vnfSearch/VnfSearchActions.test.js new file mode 100644 index 0000000..e1c3733 --- /dev/null +++ b/test/app/vnfSearch/VnfSearchActions.test.js @@ -0,0 +1,215 @@ +import configureStore from 'redux-mock-store'; +import thunk from 'redux-thunk' +import fetchMock from 'fetch-mock'; + +import { + processVnfFilterPanelCollapse, + clearVnfSearchData, + setNotificationText, + processVnfVisualizationsOnFilterChange +} from 'app/vnfSearch/VnfSearchActions.js'; +import { + vnfActionTypes, + CHART_PROV_STATUS, + CHART_ORCH_STATUS, + CHART_NF_TYPE, + CHART_NF_ROLE, + TOTAL_VNF_COUNT, + VNF_FILTER_EMPTY_RESULT +} from 'app/vnfSearch/VnfSearchConstants.js'; +import { globalInlineMessageBarActionTypes } from 'app/globalInlineMessageBar/GlobalInlineMessageBarConstants.js'; +import { ERROR_RETRIEVING_DATA } from 'app/networking/NetworkConstants.js'; + +describe('VnfSearchAction - Action Tests', () => { + it('Action: processVnfFilterPanelCollapse - open', () => { + const result = processVnfFilterPanelCollapse(true); + expect(result).toEqual({ + type: vnfActionTypes.VNF_FILTER_PANEL_TOGGLED, + data: { + vnfVisualizationPanelClass: 'collapsible-panel-main-panel vertical-filter-panel-is-open' + } + }); + }); + + it('Action: processVnfFilterPanelCollapse - close', () => { + const result = processVnfFilterPanelCollapse(false); + expect(result).toEqual({ + type: vnfActionTypes.VNF_FILTER_PANEL_TOGGLED, + data: { + vnfVisualizationPanelClass: 'collapsible-panel-main-panel' + } + }); + }); + + it('Action: clearVnfSearchData', () => { + const result = clearVnfSearchData(); + expect(result).toEqual({ + type: vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED, + data: { + count: '', + provStatusData: CHART_PROV_STATUS.emptyData, + orchStatusData: CHART_ORCH_STATUS.emptyData, + nfTypeData: CHART_NF_TYPE.emptyData, + nfRoleData: CHART_NF_ROLE.emptyData + } + }); + }); + + it('Action: setNotificationText - with message', () => { + const middlewares = [thunk]; + const mockStore = configureStore(middlewares); + const store = mockStore({ vnfSearch: {} }); + store.dispatch(setNotificationText('test error message', 'WARNING')); + const actions = store.getActions(); + expect(actions).toEqual([{ + type: globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE, + data: { + msgText: 'test error message', + msgSeverity: 'WARNING' + } + }]); + }); + + it('Action: processVnfVisualizationsOnFilterChange - data for filter values', () => { + const middlewares = [thunk]; + const mockStore = configureStore(middlewares); + const store = mockStore({ vnfSearch: {} }); + const filterValueMap = { + 1: 'Running', + 2: 'Junk', + 7: 'Blah', + 8: 'Doh' + }; + const expectedActions = [ + { type: vnfActionTypes.VNF_ACTIVATE_BUSY_FEEDBACK }, + { type: globalInlineMessageBarActionTypes.CLEAR_GLOBAL_MESSAGE }, + { + type: vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED, + data: { + count: 10, + provStatusData: { + values: [ + { x: 'junk', y: 10 } + ] + }, + orchStatusData: { + values: [ + { x: 'running', y: 10 } + ] + }, + nfTypeData: { + values: [ + { x: 'doh', y: 10 } + ] + }, + nfRoleData: { + values: [ + { x: 'blah', y: 10 } + ] + } + } + }, + { type: vnfActionTypes.VNF_DISABLE_BUSY_FEEDBACK } + ]; + fetchMock.mock('*', { + "total": 10, + "aggregations":{ + "nf-role":[{"doc_count":10,"key":"blah"}], + "nf-type":[{"doc_count":10,"key":"doh"}], + "prov-status":[{"doc_count":10,"key":"junk"}], + "orchestration-status":[{"doc_count":10,"key":"running"}] + } + }); + + return store.dispatch(processVnfVisualizationsOnFilterChange(filterValueMap)) + .then( () => { + const actions = store.getActions(); + expect(actions).toEqual(expectedActions); + fetchMock.restore(); + }); + }); + + it('Action: processVnfVisualizationsOnFilterChange - no data for filter values', () => { + const middlewares = [thunk]; + const mockStore = configureStore(middlewares); + const store = mockStore({ vnfSearch: {} }); + const filterValueMap = { + 1: 'Running', + 2: 'Junk', + 7: '', + 8: 'Doh' + }; + const expectedActions = [ + { type: vnfActionTypes.VNF_ACTIVATE_BUSY_FEEDBACK }, + { type: globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE, + data: { msgSeverity: "warning", msgText: VNF_FILTER_EMPTY_RESULT } + }, + { + type: vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED, + data: { + count: TOTAL_VNF_COUNT.emptyData, + provStatusData: CHART_PROV_STATUS.emptyData, + orchStatusData: CHART_ORCH_STATUS.emptyData, + nfTypeData: CHART_NF_TYPE.emptyData, + nfRoleData: CHART_NF_ROLE.emptyData + } + }, + { type: vnfActionTypes.VNF_DISABLE_BUSY_FEEDBACK } + ]; + fetchMock.mock('*', { + "total": 0, + "aggregations":{ + "nf-role":[], + "nf-type":[], + "prov-status":[], + "orchestration-status":[] + } + }); + + return store.dispatch(processVnfVisualizationsOnFilterChange(filterValueMap)) + .then( () => { + const actions = store.getActions(); + expect(actions).toEqual(expectedActions); + fetchMock.restore(); + }); + }); + + it('Action: processVnfVisualizationsOnFilterChange - network error', () => { + const middlewares = [thunk]; + const mockStore = configureStore(middlewares); + const store = mockStore({ vnfSearch: {} }); + const filterValueMap = { + 1: 'Running', + 2: 'Junk', + 7: 'Blah', + 8: 'Doh' + }; + const expectedActions = [ + { type: vnfActionTypes.VNF_ACTIVATE_BUSY_FEEDBACK }, + { type: vnfActionTypes.VNF_DISABLE_BUSY_FEEDBACK }, + { + type: vnfActionTypes.VNF_NETWORK_ERROR, + data: { errorMsg: ERROR_RETRIEVING_DATA } + } + ]; + fetchMock.mock('*', 503); + + return store.dispatch(processVnfVisualizationsOnFilterChange(filterValueMap)) + .then( () => { + const actions = store.getActions(); + expect(actions).toEqual(expectedActions); + fetchMock.restore(); + }); + }); + + it('Action: setNotificationText - no message', () => { + const middlewares = [thunk]; + const mockStore = configureStore(middlewares); + const store = mockStore({ vnfSearch: {} }); + store.dispatch(setNotificationText('', '')); + const actions = store.getActions(); + expect(actions).toEqual([{ + type: globalInlineMessageBarActionTypes.CLEAR_GLOBAL_MESSAGE + }]); + }); +}) diff --git a/test/app/vnfSearch/VnfSearchNfRoleVisualization.test.js b/test/app/vnfSearch/VnfSearchNfRoleVisualization.test.js new file mode 100644 index 0000000..2265e6e --- /dev/null +++ b/test/app/vnfSearch/VnfSearchNfRoleVisualization.test.js @@ -0,0 +1,154 @@ +import React from 'react'; +import { shallow, mount } from 'enzyme'; +import {Provider} from 'react-redux' +import configureStore from 'redux-mock-store'; +import { BarChart } from 'recharts'; + +import ConnectedVnfSearchNfRoleVisualization, + { VnfSearchNfRoleVisualization } from 'app/vnfSearch/VnfSearchNfRoleVisualization.jsx'; +import { CHART_NF_ROLE } from 'app/vnfSearch/VnfSearchConstants.js'; +import Spinner from 'utils/SpinnerContainer.jsx'; + +describe('VnfSearchNfRoleVisualization - Shallow render of component', () => { + let wrapper; + const processedNfRoleCountChartDataProp = { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }; + + beforeEach( () => { + wrapper = shallow( + + ); + }) + + it('Render basic component', () => { + expect(wrapper.length).toEqual(1); + expect(wrapper.hasClass('visualizations')).toEqual(true); + }); + + it('Verify Spinner is present but not visible', () => { + expect(wrapper.find(Spinner)).toHaveLength(1); + expect(wrapper.find(Spinner).props().loading).toEqual(false); + }); + + it('Verify BarChart is displayed', () => { + expect(wrapper.find(BarChart)).toHaveLength(1); + expect(wrapper.find(BarChart).props().data).toEqual(processedNfRoleCountChartDataProp.values); + }); +}) + +describe('VnfSearchNfRoleVisualization - Shallow render of component with no chart data', () => { + let wrapper; + const processedNfRoleCountChartDataProp = { + values: null + }; + + beforeEach( () => { + wrapper = shallow( + + ); + }) + + it('Visualization graph hidden', () => { + expect(wrapper.length).toEqual(1); + expect(['visualizations', 'hidden'].every(className => wrapper.hasClass(className))).toEqual(true); + }); +}) + +describe('VnfSearchNfRoleVisualization - Shallow render of component with busy feedback', () => { + let wrapper; + const processedNfRoleCountChartDataProp = { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }; + + beforeEach( () => { + wrapper = shallow( + + ); + }) + + it('Render basic component', () => { + expect(wrapper.length).toEqual(1); + expect(wrapper.hasClass('visualizations')).toEqual(true); + }); + + it('Verify Spinner is present and visible', () => { + expect(wrapper.find(Spinner)).toHaveLength(1); + expect(wrapper.find(Spinner).props().loading).toEqual(true); + }); + + it('Verify BarChart is displayed', () => { + expect(wrapper.find(BarChart)).toHaveLength(1); + expect(wrapper.find(BarChart).props().data).toEqual(processedNfRoleCountChartDataProp.values); + }); +}) + +describe('VnfSearchNfRoleVisualization - Render React Component (wrapped in )', () => { + const initialState = { + vnfSearch: { + processedNfRoleCountChartData: { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }, + enableBusyFeedback: false + } + }; + const mockStore = configureStore(); + let store, wrapper; + + beforeEach( () => { + store = mockStore(initialState); + wrapper = mount(); + }) + + it('Render the connected component', () => { + expect(wrapper.find(ConnectedVnfSearchNfRoleVisualization).length).toEqual(1); + }); + + it('Validate props from store', () => { + expect(wrapper.find(VnfSearchNfRoleVisualization).props().enableBusyFeedback).toEqual(initialState.vnfSearch.enableBusyFeedback); + expect(wrapper.find(VnfSearchNfRoleVisualization).props().processedNfRoleCountChartData).toEqual(initialState.vnfSearch.processedNfRoleCountChartData); + }); +}) + +describe('VnfSearchNfRoleVisualization - Render React Component (wrapped in ) with default props', () => { + const initialState = { + vnfSearch: {} + }; + const mockStore = configureStore(); + let store, wrapper; + + beforeEach( () => { + store = mockStore(initialState); + wrapper = mount(); + }) + + it('Render the connected component', () => { + expect(wrapper.find(ConnectedVnfSearchNfRoleVisualization).length).toEqual(1); + }); + + it('Validate default props loaded', () => { + expect(wrapper.find(VnfSearchNfRoleVisualization).props().enableBusyFeedback).toEqual(false); + expect(wrapper.find(VnfSearchNfRoleVisualization).props().processedNfRoleCountChartData).toEqual(CHART_NF_ROLE.emptyData); + }); +}) diff --git a/test/app/vnfSearch/VnfSearchNfTypeVisualization.test.js b/test/app/vnfSearch/VnfSearchNfTypeVisualization.test.js new file mode 100644 index 0000000..485a822 --- /dev/null +++ b/test/app/vnfSearch/VnfSearchNfTypeVisualization.test.js @@ -0,0 +1,154 @@ +import React from 'react'; +import { shallow, mount } from 'enzyme'; +import {Provider} from 'react-redux' +import configureStore from 'redux-mock-store'; +import { BarChart } from 'recharts'; + +import ConnectedVnfSearchNfTypeVisualization, + { VnfSearchNfTypeVisualization } from 'app/vnfSearch/VnfSearchNfTypeVisualization.jsx'; +import { CHART_NF_TYPE } from 'app/vnfSearch/VnfSearchConstants.js'; +import Spinner from 'utils/SpinnerContainer'; + +describe('VnfSearchNfTypeVisualization - Shallow render of component', () => { + let wrapper; + const processedNfTypeCountChartDataProp = { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }; + + beforeEach( () => { + wrapper = shallow( + + ); + }) + + it('Render basic component', () => { + expect(wrapper.length).toEqual(1); + expect(wrapper.hasClass('visualizations')).toEqual(true); + }); + + it('Verify Spinner is present but not visible', () => { + expect(wrapper.find(Spinner)).toHaveLength(1); + expect(wrapper.find(Spinner).props().loading).toEqual(false); + }); + + it('Verify BarChart is displayed', () => { + expect(wrapper.find(BarChart)).toHaveLength(1); + expect(wrapper.find(BarChart).props().data).toEqual(processedNfTypeCountChartDataProp.values); + }); +}) + +describe('VnfSearchNfTypeVisualization - Shallow render of component with no chart data', () => { + let wrapper; + const processedNfTypeCountChartDataProp = { + values: null + }; + + beforeEach( () => { + wrapper = shallow( + + ); + }) + + it('Visualization graph hidden', () => { + expect(wrapper.length).toEqual(1); + expect(['visualizations', 'hidden'].every(className => wrapper.hasClass(className))).toEqual(true); + }); +}) + +describe('VnfSearchNfTypeVisualization - Shallow render of component with busy feedback', () => { + let wrapper; + const processedNfTypeCountChartDataProp = { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }; + + beforeEach( () => { + wrapper = shallow( + + ); + }) + + it('Render basic component', () => { + expect(wrapper.length).toEqual(1); + expect(wrapper.hasClass('visualizations')).toEqual(true); + }); + + it('Verify Spinner is present and visible', () => { + expect(wrapper.find(Spinner)).toHaveLength(1); + expect(wrapper.find(Spinner).props().loading).toEqual(true); + }); + + it('Verify BarChart is displayed', () => { + expect(wrapper.find(BarChart)).toHaveLength(1); + expect(wrapper.find(BarChart).props().data).toEqual(processedNfTypeCountChartDataProp.values); + }); +}) + +describe('VnfSearchNfTypeVisualization - Render React Component (wrapped in )', () => { + const initialState = { + vnfSearch: { + processedNfTypeCountChartData: { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }, + enableBusyFeedback: false + } + }; + const mockStore = configureStore(); + let store, wrapper; + + beforeEach( () => { + store = mockStore(initialState); + wrapper = mount(); + }) + + it('Render the connected component', () => { + expect(wrapper.find(ConnectedVnfSearchNfTypeVisualization).length).toEqual(1); + }); + + it('Validate props from store', () => { + expect(wrapper.find(VnfSearchNfTypeVisualization).props().enableBusyFeedback).toEqual(initialState.vnfSearch.enableBusyFeedback); + expect(wrapper.find(VnfSearchNfTypeVisualization).props().processedNfTypeCountChartData).toEqual(initialState.vnfSearch.processedNfTypeCountChartData); + }); +}) + +describe('VnfSearchNfTypeVisualization - Render React Component (wrapped in ) with default props', () => { + const initialState = { + vnfSearch: {} + }; + const mockStore = configureStore(); + let store, wrapper; + + beforeEach( () => { + store = mockStore(initialState); + wrapper = mount(); + }) + + it('Render the connected component', () => { + expect(wrapper.find(ConnectedVnfSearchNfTypeVisualization).length).toEqual(1); + }); + + it('Validate default props loaded', () => { + expect(wrapper.find(VnfSearchNfTypeVisualization).props().enableBusyFeedback).toEqual(false); + expect(wrapper.find(VnfSearchNfTypeVisualization).props().processedNfTypeCountChartData).toEqual(CHART_NF_TYPE.emptyData); + }); +}) diff --git a/test/app/vnfSearch/VnfSearchOrchestratedStatusVisualization.test.js b/test/app/vnfSearch/VnfSearchOrchestratedStatusVisualization.test.js new file mode 100644 index 0000000..2586079 --- /dev/null +++ b/test/app/vnfSearch/VnfSearchOrchestratedStatusVisualization.test.js @@ -0,0 +1,154 @@ +import React from 'react'; +import { shallow, mount } from 'enzyme'; +import {Provider} from 'react-redux' +import configureStore from 'redux-mock-store'; +import { BarChart } from 'recharts'; + +import ConnectedVnfSearchOrchStatusVisualizations, + { VnfSearchOrchStatusVisualizations } from 'app/vnfSearch/VnfSearchOrchestratedStatusVisualization.jsx'; +import { CHART_ORCH_STATUS } from 'app/vnfSearch/VnfSearchConstants.js'; +import Spinner from 'utils/SpinnerContainer'; + +describe('VnfSearchOrchStatusVisualizations - Shallow render of component', () => { + let wrapper; + const processedOrchStatusCountChartDataProp = { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }; + + beforeEach( () => { + wrapper = shallow( + + ); + }) + + it('Render basic component', () => { + expect(wrapper.length).toEqual(1); + expect(wrapper.hasClass('visualizations')).toEqual(true); + }); + + it('Verify Spinner is present but not visible', () => { + expect(wrapper.find(Spinner)).toHaveLength(1); + expect(wrapper.find(Spinner).props().loading).toEqual(false); + }); + + it('Verify BarChart is displayed', () => { + expect(wrapper.find(BarChart)).toHaveLength(1); + expect(wrapper.find(BarChart).props().data).toEqual(processedOrchStatusCountChartDataProp.values); + }); +}) + +describe('VnfSearchOrchStatusVisualizations - Shallow render of component with no chart data', () => { + let wrapper; + const processedOrchStatusCountChartDataProp = { + values: null + }; + + beforeEach( () => { + wrapper = shallow( + + ); + }) + + it('Visualization graph hidden', () => { + expect(wrapper.length).toEqual(1); + expect(['visualizations', 'hidden'].every(className => wrapper.hasClass(className))).toEqual(true); + }); +}) + +describe('VnfSearchOrchStatusVisualizations - Shallow render of component with busy feedback', () => { + let wrapper; + const processedOrchStatusCountChartDataProp = { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }; + + beforeEach( () => { + wrapper = shallow( + + ); + }) + + it('Render basic component', () => { + expect(wrapper.length).toEqual(1); + expect(wrapper.hasClass('visualizations')).toEqual(true); + }); + + it('Verify Spinner is present and visible', () => { + expect(wrapper.find(Spinner)).toHaveLength(1); + expect(wrapper.find(Spinner).props().loading).toEqual(true); + }); + + it('Verify BarChart is displayed', () => { + expect(wrapper.find(BarChart)).toHaveLength(1); + expect(wrapper.find(BarChart).props().data).toEqual(processedOrchStatusCountChartDataProp.values); + }); +}) + +describe('VnfSearchOrchStatusVisualizations - Render React Component (wrapped in )', () => { + const initialState = { + vnfSearch: { + processedOrchStatusCountChartData: { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }, + enableBusyFeedback: false + } + }; + const mockStore = configureStore(); + let store, wrapper; + + beforeEach( () => { + store = mockStore(initialState); + wrapper = mount(); + }) + + it('Render the connected component', () => { + expect(wrapper.find(ConnectedVnfSearchOrchStatusVisualizations).length).toEqual(1); + }); + + it('Validate props from store', () => { + expect(wrapper.find(VnfSearchOrchStatusVisualizations).props().enableBusyFeedback).toEqual(initialState.vnfSearch.enableBusyFeedback); + expect(wrapper.find(VnfSearchOrchStatusVisualizations).props().processedOrchStatusCountChartData).toEqual(initialState.vnfSearch.processedOrchStatusCountChartData); + }); +}) + +describe('VnfSearchOrchStatusVisualizations - Render React Component (wrapped in ) with default props', () => { + const initialState = { + vnfSearch: {} + }; + const mockStore = configureStore(); + let store, wrapper; + + beforeEach( () => { + store = mockStore(initialState); + wrapper = mount(); + }) + + it('Render the connected component', () => { + expect(wrapper.find(ConnectedVnfSearchOrchStatusVisualizations).length).toEqual(1); + }); + + it('Validate default props loaded', () => { + expect(wrapper.find(VnfSearchOrchStatusVisualizations).props().enableBusyFeedback).toEqual(false); + expect(wrapper.find(VnfSearchOrchStatusVisualizations).props().processedOrchStatusCountChartData).toEqual(CHART_ORCH_STATUS.emptyData); + }); +}) diff --git a/test/app/vnfSearch/VnfSearchProvStatusVisualization.test.js b/test/app/vnfSearch/VnfSearchProvStatusVisualization.test.js new file mode 100644 index 0000000..f3e7279 --- /dev/null +++ b/test/app/vnfSearch/VnfSearchProvStatusVisualization.test.js @@ -0,0 +1,154 @@ +import React from 'react'; +import { shallow, mount } from 'enzyme'; +import {Provider} from 'react-redux' +import configureStore from 'redux-mock-store'; +import { BarChart } from 'recharts'; + +import ConnectedVnfSearchProvStatusVisualization, + { VnfSearchProvStatusVisualization } from 'app/vnfSearch/VnfSearchProvStatusVisualization.jsx'; +import { CHART_PROV_STATUS } from 'app/vnfSearch/VnfSearchConstants.js'; +import Spinner from 'utils/SpinnerContainer'; + +describe('VnfSearchProvStatusVisualization - Shallow render of component', () => { + let wrapper; + const processedProvStatusCountChartDataProp = { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }; + + beforeEach( () => { + wrapper = shallow( + + ); + }) + + it('Render basic component', () => { + expect(wrapper.length).toEqual(1); + expect(wrapper.hasClass('visualizations')).toEqual(true); + }); + + it('Verify Spinner is present but not visible', () => { + expect(wrapper.find(Spinner)).toHaveLength(1); + expect(wrapper.find(Spinner).props().loading).toEqual(false); + }); + + it('Verify BarChart is displayed', () => { + expect(wrapper.find(BarChart)).toHaveLength(1); + expect(wrapper.find(BarChart).props().data).toEqual(processedProvStatusCountChartDataProp.values); + }); +}) + +describe('VnfSearchProvStatusVisualization - Shallow render of component with no chart data', () => { + let wrapper; + const processedProvStatusCountChartDataProp = { + values: null + }; + + beforeEach( () => { + wrapper = shallow( + + ); + }) + + it('Visualization graph hidden', () => { + expect(wrapper.length).toEqual(1); + expect(['visualizations', 'hidden'].every(className => wrapper.hasClass(className))).toEqual(true); + }); +}) + +describe('VnfSearchProvStatusVisualization - Shallow render of component with busy feedback', () => { + let wrapper; + const processedProvStatusCountChartDataProp = { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }; + + beforeEach( () => { + wrapper = shallow( + + ); + }) + + it('Render basic component', () => { + expect(wrapper.length).toEqual(1); + expect(wrapper.hasClass('visualizations')).toEqual(true); + }); + + it('Verify Spinner is present and visible', () => { + expect(wrapper.find(Spinner)).toHaveLength(1); + expect(wrapper.find(Spinner).props().loading).toEqual(true); + }); + + it('Verify BarChart is displayed', () => { + expect(wrapper.find(BarChart)).toHaveLength(1); + expect(wrapper.find(BarChart).props().data).toEqual(processedProvStatusCountChartDataProp.values); + }); +}) + +describe('VnfSearchProvStatusVisualization - Render React Component (wrapped in )', () => { + const initialState = { + vnfSearch: { + processedProvStatusCountChartData: { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }, + enableBusyFeedback: false + } + }; + const mockStore = configureStore(); + let store, wrapper; + + beforeEach( () => { + store = mockStore(initialState); + wrapper = mount(); + }) + + it('Render the connected component', () => { + expect(wrapper.find(ConnectedVnfSearchProvStatusVisualization).length).toEqual(1); + }); + + it('Validate props from store', () => { + expect(wrapper.find(VnfSearchProvStatusVisualization).props().enableBusyFeedback).toEqual(initialState.vnfSearch.enableBusyFeedback); + expect(wrapper.find(VnfSearchProvStatusVisualization).props().processedProvStatusCountChartData).toEqual(initialState.vnfSearch.processedProvStatusCountChartData); + }); +}) + +describe('VnfSearchProvStatusVisualization - Render React Component (wrapped in ) with default props', () => { + const initialState = { + vnfSearch: {} + }; + const mockStore = configureStore(); + let store, wrapper; + + beforeEach( () => { + store = mockStore(initialState); + wrapper = mount(); + }) + + it('Render the connected component', () => { + expect(wrapper.find(ConnectedVnfSearchProvStatusVisualization).length).toEqual(1); + }); + + it('Validate default props loaded', () => { + expect(wrapper.find(VnfSearchProvStatusVisualization).props().enableBusyFeedback).toEqual(false); + expect(wrapper.find(VnfSearchProvStatusVisualization).props().processedProvStatusCountChartData).toEqual(CHART_PROV_STATUS.emptyData); + }); +}) diff --git a/test/app/vnfSearch/VnfSearchReducer.test.js b/test/app/vnfSearch/VnfSearchReducer.test.js new file mode 100644 index 0000000..381a696 --- /dev/null +++ b/test/app/vnfSearch/VnfSearchReducer.test.js @@ -0,0 +1,438 @@ +import VnfSearchReducer from 'app/vnfSearch/VnfSearchReducer.js'; +import { + vnfActionTypes, + CHART_ORCH_STATUS, + CHART_PROV_STATUS, + CHART_NF_ROLE, + CHART_NF_TYPE, + TOTAL_VNF_COUNT +} from 'app/vnfSearch/VnfSearchConstants.js'; +import {ERROR_RETRIEVING_DATA} from 'app/networking/NetworkConstants.js'; +import { + filterBarActionTypes, + MESSAGE_LEVEL_DANGER +} from 'utils/GlobalConstants'; +import { + globalAutoCompleteSearchBarActionTypes +} from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants.js'; + +describe('VnfSearchReducer - Reducer Action Type Tests', () => { + it('Action Type: VNF_NETWORK_ERROR', () => { + const action = { + type: vnfActionTypes.VNF_NETWORK_ERROR + }; + let state = { + processedProvStatusCountChartData: { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }, + processedOrchStatusCountChartData: { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }, + processedNfTypeCountChartData: { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }, + processedNfRoleCountChartData: { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }, + count: 20, + feedbackMsgText: '', + feedbackMsgSeverity: '' + }; + state = VnfSearchReducer(state, action); + expect(state).toEqual({ + processedProvStatusCountChartData: CHART_PROV_STATUS.emptyData, + processedOrchStatusCountChartData: CHART_ORCH_STATUS.emptyData, + processedNfTypeCountChartData: CHART_NF_TYPE.emptyData, + processedNfRoleCountChartData: CHART_NF_ROLE.emptyData, + count: TOTAL_VNF_COUNT.emptyValue, + feedbackMsgText: ERROR_RETRIEVING_DATA, + feedbackMsgSeverity: MESSAGE_LEVEL_DANGER + }); + }); + + it('Action Type: SEARCH_WARNING_EVENT', () => { + const action = { + type: globalAutoCompleteSearchBarActionTypes.SEARCH_WARNING_EVENT + }; + let state = { + processedProvStatusCountChartData: { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }, + processedOrchStatusCountChartData: { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }, + processedNfTypeCountChartData: { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }, + processedNfRoleCountChartData: { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }, + count: 20, + }; + state = VnfSearchReducer(state, action); + expect(state).toEqual({ + processedProvStatusCountChartData: CHART_PROV_STATUS.emptyData, + processedOrchStatusCountChartData: CHART_ORCH_STATUS.emptyData, + processedNfTypeCountChartData: CHART_NF_TYPE.emptyData, + processedNfRoleCountChartData: CHART_NF_ROLE.emptyData, + count: TOTAL_VNF_COUNT.emptyValue, + }); + }); + + it('Action Type: NEW_SELECTIONS', () => { + const action = { + type: filterBarActionTypes.NEW_SELECTIONS, + data: { + selectedValuesMap: [ + { filter1: ['someValue'] } + ], + unifiedValues: [ + { filter1: ['someValue', 'someOtherValue']} + ] + } + }; + let state = { + vnfFilterValues: {}, + unifiedFilterValues: {} + }; + state = VnfSearchReducer(state, action); + expect(state).toEqual({ + vnfFilterValues: action.data.selectedValuesMap, + unifiedFilterValues: action.data.unifiedValues + }); + }); + + it('Action Type: SET_UNIFIED_VALUES', () => { + const action = { + type: filterBarActionTypes.SET_UNIFIED_VALUES, + data: { + unifiedValues: [ + { filter1: ['someValue', 'someOtherValue']} + ] + } + }; + let state = { + unifiedFilterValues: {} + }; + state = VnfSearchReducer(state, action); + expect(state).toEqual({ + unifiedFilterValues: action.data + }); + }); + + it('Action Type: VNF_SEARCH_RESULTS_RECEIVED', () => { + const action = { + type: vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED, + data: { + provStatusData: { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }, + orchStatusData: { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }, + nfTypeData: { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }, + nfRoleData: { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }, + count: 25, + } + }; + let state = { + processedProvStatusCountChartData: {}, + processedOrchStatusCountChartData: {}, + processedNfTypeCountChartData: {}, + processedNfRoleCountChartData: {}, + count: 0, + feedbackMsgText: 'some error msg', + feedbackMsgSeverity: 'someSeverityLevel' + }; + state = VnfSearchReducer(state, action); + expect(state).toEqual({ + processedProvStatusCountChartData: action.data.provStatusData, + processedOrchStatusCountChartData: action.data.orchStatusData, + processedNfTypeCountChartData: action.data.nfTypeData, + processedNfRoleCountChartData: action.data.nfRoleData, + count: action.data.count, + feedbackMsgText: '', + feedbackMsgSeverity: '' + }); + }); + + it('Action Type: VNF_FILTER_PANEL_TOGGLED', () => { + const action = { + type: vnfActionTypes.VNF_FILTER_PANEL_TOGGLED, + data: { + vnfVisualizationPanelClass: 'hide', + } + }; + let state = { + vnfVisualizationPanelClass: 'show' + }; + state = VnfSearchReducer(state, action); + expect(state).toEqual({ + vnfVisualizationPanelClass: 'hide' + }); + }); + + it('Action Type: VNF_SEARCH_FILTERS_RECEIVED', () => { + const action = { + type: vnfActionTypes.VNF_SEARCH_FILTERS_RECEIVED, + data: [ + { filter1: 'value 1' }, + { filter2: 'value 2' } + ] + }; + let state = { + vnfFilters: [] + }; + state = VnfSearchReducer(state, action); + expect(state).toEqual({ + vnfFilters: action.data + }); + }); + + it('Action Type: SET_NON_CONVERTED_VALUES', () => { + const action = { + type: filterBarActionTypes.SET_NON_CONVERTED_VALUES, + data: [ + { value1: 'abc' }, + { value2: 'xyz' } + ] + }; + let state = { + nonConvertedFilters: [] + }; + state = VnfSearchReducer(state, action); + expect(state).toEqual({ + nonConvertedFilters: action.data + }); + }); + + it('Action Type: SET_CONVERTED_VALUES', () => { + const action = { + type: filterBarActionTypes.SET_CONVERTED_VALUES, + data: { + convertedValues: { + value1: 'abc', + value2: 'xyz' + }, + nonConvertedValues: { + value1: 123, + value2: 456 + } + } + }; + let state = { + nonConvertedFilters: { + filter1: 'one', + filter2: 'two' + }, + unifiedFilterValues: {}, + vnfFilterValues: {} + }; + state = VnfSearchReducer(state, action); + expect(state).toEqual({ + nonConvertedFilters: {}, + unifiedFilterValues: action.data.convertedValues, + vnfFilterValues: action.data.nonConvertedValues + }); + }); + + it('Action Type: VNF_ACTIVATE_BUSY_FEEDBACK', () => { + const action = { + type: vnfActionTypes.VNF_ACTIVATE_BUSY_FEEDBACK + }; + let state = { + enableBusyFeedback: false + }; + state = VnfSearchReducer(state, action); + expect(state).toEqual({ + enableBusyFeedback: true + }); + }); + + it('Action Type: VNF_DISABLE_BUSY_FEEDBACK', () => { + const action = { + type: vnfActionTypes.VNF_DISABLE_BUSY_FEEDBACK + }; + let state = { + enableBusyFeedback: true + }; + state = VnfSearchReducer(state, action); + expect(state).toEqual({ + enableBusyFeedback: false + }); + }); + + it('Action Type: CLEAR_FILTERS', () => { + const action = { + type: filterBarActionTypes.CLEAR_FILTERS + }; + let state = { + vnfFilters: { + filter1: 'filterName1' + }, + vnfFilterValues: { + filter1: 'value 1' + }, + nonConvertedFilters: { + nonConvertedFilter1: 'some fitler props' + }, + unifiedFilterValues: { + unifiedFilter1: 'some unified props' + } + }; + state = VnfSearchReducer(state, action); + expect(state).toEqual({ + vnfFilters: {}, + vnfFilterValues: {}, + nonConvertedFilters: {}, + unifiedFilterValues: {} + }); + }); + + it('Invalid Action Type', () => { + const action = { + type: 'Nonexistent Action Type', + }; + let state = { + vnfFilters: { + filter1: 'filterName1' + }, + vnfFilterValues: { + filter1: 'value 1' + }, + nonConvertedFilters: { + nonConvertedFilter1: 'some fitler props' + }, + unifiedFilterValues: { + unifiedFilter1: 'some unified props' + }, + enableBusyFeedback: true, + provStatusData: { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }, + orchStatusData: { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }, + nfTypeData: { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }, + nfRoleData: { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }, + count: 25 + }; + state = VnfSearchReducer(state, action); + expect(state).toEqual({ + vnfFilters: { + filter1: 'filterName1' + }, + vnfFilterValues: { + filter1: 'value 1' + }, + nonConvertedFilters: { + nonConvertedFilter1: 'some fitler props' + }, + unifiedFilterValues: { + unifiedFilter1: 'some unified props' + }, + enableBusyFeedback: true, + provStatusData: { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }, + orchStatusData: { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }, + nfTypeData: { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }, + nfRoleData: { + values: [ + {x: 'col 1', y: 3}, + {x: 'col 2', y: 7}, + {x: 'col 3', y: 2} + ] + }, + count: 25 + }); + }); +}) diff --git a/test/app/vnfSearch/VnfSearchTotalCountVisualization.test.js b/test/app/vnfSearch/VnfSearchTotalCountVisualization.test.js new file mode 100644 index 0000000..a397ff2 --- /dev/null +++ b/test/app/vnfSearch/VnfSearchTotalCountVisualization.test.js @@ -0,0 +1,131 @@ +import React from 'react'; +import { shallow, mount } from 'enzyme'; +import {Provider} from 'react-redux' +import configureStore from 'redux-mock-store'; + +import ConnectedVnfSearchTotalCountVisualization, + { VnfSearchTotalCountVisualization } from 'app/vnfSearch/VnfSearchTotalCountVisualization.jsx'; +import { TOTAL_VNF_COUNT } from 'app/vnfSearch/VnfSearchConstants.js'; +import Spinner from 'utils/SpinnerContainer'; + +describe('VnfSearchTotalCountVisualization - Shallow render of component', () => { + let wrapper; + const countProp = 25; + + beforeEach( () => { + wrapper = shallow( + + ); + }) + + it('Render basic component', () => { + expect(wrapper.length).toEqual(1); + expect(wrapper.hasClass('visualizations')).toEqual(true); + }); + + it('Verify Spinner is present but not visible', () => { + expect(wrapper.find(Spinner)).toHaveLength(1); + expect(wrapper.find(Spinner).props().loading).toEqual(false); + }); + + it('Verify total count is displayed', () => { + expect(wrapper.contains({countProp})).toBe(true); + }); +}) + +describe('VnfSearchTotalCountVisualization - Shallow render of component with no chart data', () => { + let wrapper; + const countProp = null; + + beforeEach( () => { + wrapper = shallow( + + ); + }) + + it('Visualization graph hidden', () => { + expect(wrapper.length).toEqual(1); + expect(['visualizations', 'hidden'].every(className => wrapper.hasClass(className))).toEqual(true); + }); +}) + +describe('VnfSearchTotalCountVisualization - Shallow render of component with busy feedback', () => { + let wrapper; + const countProp = 25; + + beforeEach( () => { + wrapper = shallow( + + ); + }) + + it('Render basic component', () => { + expect(wrapper.length).toEqual(1); + expect(wrapper.hasClass('visualizations')).toEqual(true); + }); + + it('Verify Spinner is present and visible', () => { + expect(wrapper.find(Spinner)).toHaveLength(1); + expect(wrapper.find(Spinner).props().loading).toEqual(true); + }); + + it('Verify total count is displayed', () => { + expect(wrapper.contains({countProp})).toBe(true); + }); +}) + +describe('VnfSearchTotalCountVisualization - Render React Component (wrapped in )', () => { + const initialState = { + vnfSearch: { + count: 25, + enableBusyFeedback: false + } + }; + const mockStore = configureStore(); + let store, wrapper; + + beforeEach( () => { + store = mockStore(initialState); + wrapper = mount(); + }) + + it('Render the connected component', () => { + expect(wrapper.find(ConnectedVnfSearchTotalCountVisualization).length).toEqual(1); + }); + + it('Validate props from store', () => { + expect(wrapper.find(VnfSearchTotalCountVisualization).props().enableBusyFeedback).toEqual(initialState.vnfSearch.enableBusyFeedback); + expect(wrapper.find(VnfSearchTotalCountVisualization).props().count).toEqual(initialState.vnfSearch.count); + }); +}) + +describe('VnfSearchTotalCountVisualization - Render React Component (wrapped in ) with default props', () => { + const initialState = { + vnfSearch: {} + }; + const mockStore = configureStore(); + let store, wrapper; + + beforeEach( () => { + store = mockStore(initialState); + wrapper = mount(); + }) + + it('Render the connected component', () => { + expect(wrapper.find(ConnectedVnfSearchTotalCountVisualization).length).toEqual(1); + }); + + it('Validate default props loaded', () => { + expect(wrapper.find(VnfSearchTotalCountVisualization).props().enableBusyFeedback).toEqual(false); + expect(wrapper.find(VnfSearchTotalCountVisualization).props().count).toEqual(TOTAL_VNF_COUNT.emptyValue); + }); +}) diff --git a/test/autoCompleteSearchBar/AutoCompleteSearchBar.test.js b/test/autoCompleteSearchBar/AutoCompleteSearchBar.test.js deleted file mode 100644 index 7ba3d11..0000000 --- a/test/autoCompleteSearchBar/AutoCompleteSearchBar.test.js +++ /dev/null @@ -1,40 +0,0 @@ -import React from 'react'; -import { shallow } from 'enzyme'; -import {Provider} from 'react-redux' -import configureStore from 'redux-mock-store'; - -import AutoCompleteSearchBar from 'generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.jsx'; - -describe('AutoCompleteSearchBarTests', () => { - const suggestions = [ - { - text: 'Apple' - }, - { - text: 'Orange' - }, - { - text: 'Banana' - } - ]; - const initialState = { - globalAutoCompleteSearchBarReducer: { - value: '', - suggestions: [], - cachedSuggestions: [], - suggestionName: '' - } - }; - const mockStore = configureStore(); - let store, wrapper; - - beforeEach( () => { - store = mockStore(initialState); - wrapper = shallow(); - }) - - it('render search bar - visible', () => { - expect(wrapper).toHaveLength(1); // ensure the message bar is mounted - expect(wrapper.find(AutoCompleteSearchBar)).toHaveLength(1); // ensure the InlineMessage is mounted - }); -}) diff --git a/test/configurableViews/ConfigurableViewActions.test.js b/test/configurableViews/ConfigurableViewActions.test.js deleted file mode 100644 index 9d7bc9e..0000000 --- a/test/configurableViews/ConfigurableViewActions.test.js +++ /dev/null @@ -1,208 +0,0 @@ -import configureStore from 'redux-mock-store'; -import thunk from 'redux-thunk' -import fetchMock from 'fetch-mock'; -import { - configurableViewsActionTypes -} from 'app/configurableViews/ConfigurableViewConstants.js'; -import { - newCustomComponentsEvent, - setCustomRoutes, - getConfigurableViewConfigs -} from 'app/configurableViews/ConfigurableViewActions.js' - - -describe('ConfigurableViewActionTests', () => { - const sampleConfig = { - "id": "aggregateReport", - "title": "Aggregate Report", - "iconURL": "resources/images/sampleAggReportIcon.svg", - "iconHoverURL": "resources/images/sampleAggReportIconHover.svg", - "viewType": "ConfigurableCardView", - "layout": { - "draggable": true, - "resizable": true, - "rowHeight": 100, - "cardMargin": [ - 20, - 20 - ], - "cardPadding": [ - 20, - 20 - ], - "breakpoints": [ - { - "id": "lg", - "col": 12, - "width": 1400 - }, - { - "id": "md", - "col": 8, - "width": 1200 - }, - { - "id": "sm", - "col": 6, - "width": 1024 - } - ] - }, - "components": [ - { - "id": "visualization1", - "title": "Total VNFs", - "queryData": { - "eventId": "visualization1", - "api": "/get-component-data", - "method": "POST", - "headers": { - "accept": "application/json" - }, - "componentDataDescriptor": { - "index": "aggregate_generic-vnf_index", - "queryType": "aggregation", - "query": { - "filter": {}, - "queries": [], - "aggregations": [ - { - "name": "prov-status", - "aggregation": { - "group-by": { - "field": "prov-status", - "size": 0 - } - } - }, - { - "name": "orchestration-status", - "aggregation": { - "group-by": { - "field": "orchestration-status", - "size": 0 - } - } - }, - { - "name": "nf-type", - "aggregation": { - "group-by": { - "field": "nf-type", - "size": 0 - } - } - }, - { - "name": "nf-role", - "aggregation": { - "group-by": { - "field": "nf-role", - "size": 0 - } - } - } - ] - }, - "responseTransformation": { - "type": "count", - "spec": { - "countType": "total", - "countResponseLabel": "display" - } - } - } - }, - "containerData": { - "containerType": "NetworkQueryCard", - "visualizationType": "text", - "visualizationProp": { - "display": "", - "style": { - "textAlign": "center", - "fontSize": "50px", - "fontWeight": "bold", - "paddingTop": "50px" - } - }, - "breakpoints": { - "lg": { - "w": 2, - "h": 2, - "x": 0, - "y": 0 - }, - "md": { - "w": 2, - "h": 2, - "x": 0, - "y": 0 - }, - "sm": { - "w": 6, - "h": 2, - "x": 0, - "y": 0 - } - } - } - } - ] - }; - - it('newCustomComponentsEvent', () => { - const components = [ - { - compId: 'someId', - compName: 'Some Name' - } - ]; - const middlewares = [thunk]; - const mockStore = configureStore(middlewares); - const store = mockStore({}); - store.dispatch(newCustomComponentsEvent(components)); - const actions = store.getActions(); - expect(actions).toEqual([{ - type: configurableViewsActionTypes.CUSTOM_COMPONENTS_RECEIVED, - data: components - }]); - }); - - it('setCustomRoutes', () => { - const routes = [ - { - routeName: 'Some Custom Route', - path: 'some/route/path' - } - ]; - const middlewares = [thunk]; - const mockStore = configureStore(middlewares); - const store = mockStore({}); - store.dispatch(setCustomRoutes(routes)); - const actions = store.getActions(); - expect(actions).toEqual([{ - type: configurableViewsActionTypes.CUSTOM_ROUTES, - data: routes - }]); - }); - - it('getConfigurableViewConfigs', () => { - const middlewares = [thunk]; - const mockStore = configureStore(middlewares); - const store = mockStore({}); - const expectedActions = [ - { - type: configurableViewsActionTypes.CONFIGURABLE_VIEWS_CONFIG_RECEIVED, - data: sampleConfig - } - ]; - fetchMock.mock('*', sampleConfig); - - return store.dispatch(getConfigurableViewConfigs()) - .then( () => { - const actions = store.getActions(); - expect(actions).toEqual(expectedActions); - fetchMock.restore(); - }); - }); -}) diff --git a/test/configurableViews/ConfigurableViewReducer.test.js b/test/configurableViews/ConfigurableViewReducer.test.js deleted file mode 100644 index 0c5c46e..0000000 --- a/test/configurableViews/ConfigurableViewReducer.test.js +++ /dev/null @@ -1,54 +0,0 @@ -import { - configurableViewsActionTypes -} from 'app/configurableViews/ConfigurableViewConstants.js'; -import ConfigurableViewReducer from 'app/configurableViews/ConfigurableViewReducer.js' -describe('ConfigurableViewsReducerTests', () => { - it('Action Type: CONFIGURABLE_VIEWS_CONFIG_RECEIVED', () => { - const data = { - viewId: 'someViewId', - viewName: 'Some View Name', - viewRoute: 'some/view/route' - }; - const action = { - type: configurableViewsActionTypes.CONFIGURABLE_VIEWS_CONFIG_RECEIVED, - data: data - }; - let state = {}; - state = ConfigurableViewReducer(state, action); - expect(state).toEqual({ - configurableViewsConfig: data - }); - }); - - it('Action Type: CUSTOM_COMPONENTS_RECEIVED', () => { - const data = { - componentName: 'someComponentName', - componentData: { - blah: 'blah', - filler: 'filler' - } - }; - const action = { - type: configurableViewsActionTypes.CUSTOM_COMPONENTS_RECEIVED, - data: data - }; - let state = {}; - state = ConfigurableViewReducer(state, action); - expect(state).toEqual({ - customComponents: data - }); - }); - - it('Action Type: CUSTOM_ROUTES', () => { - const data = 'some/custom/route'; - const action = { - type: configurableViewsActionTypes.CUSTOM_ROUTES, - data: data - }; - let state = {}; - state = ConfigurableViewReducer(state, action); - expect(state).toEqual({ - customRoutes: data - }); - }); -}) diff --git a/test/generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.test.js b/test/generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.test.js new file mode 100644 index 0000000..7ba3d11 --- /dev/null +++ b/test/generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.test.js @@ -0,0 +1,40 @@ +import React from 'react'; +import { shallow } from 'enzyme'; +import {Provider} from 'react-redux' +import configureStore from 'redux-mock-store'; + +import AutoCompleteSearchBar from 'generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.jsx'; + +describe('AutoCompleteSearchBarTests', () => { + const suggestions = [ + { + text: 'Apple' + }, + { + text: 'Orange' + }, + { + text: 'Banana' + } + ]; + const initialState = { + globalAutoCompleteSearchBarReducer: { + value: '', + suggestions: [], + cachedSuggestions: [], + suggestionName: '' + } + }; + const mockStore = configureStore(); + let store, wrapper; + + beforeEach( () => { + store = mockStore(initialState); + wrapper = shallow(); + }) + + it('render search bar - visible', () => { + expect(wrapper).toHaveLength(1); // ensure the message bar is mounted + expect(wrapper.find(AutoCompleteSearchBar)).toHaveLength(1); // ensure the InlineMessage is mounted + }); +}) diff --git a/test/generic-components/notifications/NotificationReducer.test.js b/test/generic-components/notifications/NotificationReducer.test.js deleted file mode 100644 index 40d6b05..0000000 --- a/test/generic-components/notifications/NotificationReducer.test.js +++ /dev/null @@ -1,197 +0,0 @@ -import NotificationReducer from 'generic-components/notifications/NotificationReducer'; -import NotificationConstants from "generic-components/notifications/NotificationConstants"; - - -describe('NotificationReducer', () => { - const defaultState = { - type: 'default', - title: 'some default title', - msg: 'some default message', - timeout: 1 - }; - - it('Should return default state when action type is not supported', () => { - // given - const unsupportedAction = { - type: undefined - }; - - // when - const actualState = NotificationReducer(defaultState, unsupportedAction); - - // then - expect(actualState).toEqual(defaultState); - }); - - it('Should return state with type default when action type is info', () => { - // given - const expectedState = { - type: 'default', - title: 'some title', - msg: 'some message', - timeout: 5 - }; - - const infoAction = { - type: NotificationConstants.NOTIFY_INFO, - data: { - title: "some title", - msg: "some message", - timeout: 5 - } - }; - - // when - const actualState = NotificationReducer(defaultState, infoAction); - - // then - expect(actualState).toEqual(expectedState); - }); - - - it('Should return status with type success when action type is success', () => { - // given - const expectedState = { - type: 'success', - title: 'some title', - msg: 'some message', - timeout: 2 - }; - - const infoAction = { - type: NotificationConstants.NOTIFY_SUCCESS, - data: { - title: "some title", - msg: "some message", - timeout: 2 - } - }; - - // when - const actualState = NotificationReducer(defaultState, infoAction); - - // then - expect(actualState).toEqual(expectedState); - }); - - it('Should return status with type success when action type is success', () => { - // given - const expectedState = { - type: 'success', - title: 'some title', - msg: 'some message', - timeout: 2 - }; - - const infoAction = { - type: NotificationConstants.NOTIFY_SUCCESS, - data: { - title: "some title", - msg: "some message", - timeout: 2 - } - }; - - // when - const actualState = NotificationReducer(defaultState, infoAction); - - // then - expect(actualState).toEqual(expectedState); - }); - - it('Should return status with type error when action type is error', () => { - // given - const expectedState = { - type: 'error', - title: 'some title', - msg: 'some message', - timeout: 2 - }; - - const infoAction = { - type: NotificationConstants.NOTIFY_ERROR, - data: { - title: "some title", - msg: "some message", - timeout: 2 - } - }; - - // when - const actualState = NotificationReducer(defaultState, infoAction); - - // then - expect(actualState).toEqual(expectedState); - }); - - it('Should return status with type error when action type is error', () => { - // given - const expectedState = { - type: 'error', - title: 'some title', - msg: 'some message', - timeout: 2 - }; - - const infoAction = { - type: NotificationConstants.NOTIFY_ERROR, - data: { - title: "some title", - msg: "some message", - timeout: 2 - } - }; - - // when - const actualState = NotificationReducer(defaultState, infoAction); - - // then - expect(actualState).toEqual(expectedState); - }); - - it('Should return status with type warning when action type is warning', () => { - // given - const expectedState = { - type: 'warning', - title: 'some title', - msg: 'some message', - timeout: 2 - }; - - const infoAction = { - type: NotificationConstants.NOTIFY_WARNING, - data: { - title: "some title", - msg: "some message", - timeout: 2 - } - }; - - // when - const actualState = NotificationReducer(defaultState, infoAction); - - // then - expect(actualState).toEqual(expectedState); - }); - - it('Should return null when action type is close', () => { - // given - const expectedState = null; - - const infoAction = { - type: NotificationConstants.NOTIFY_CLOSE, - data: { - title: "some title", - msg: "some message", - timeout: 2 - } - }; - - // when - const actualState = NotificationReducer(defaultState, infoAction); - - // then - expect(actualState).toEqual(expectedState); - }); - -}); diff --git a/test/generic-components/treeNode/TreeNode.test.js b/test/generic-components/treeNode/TreeNode.test.js deleted file mode 100644 index 1c669e6..0000000 --- a/test/generic-components/treeNode/TreeNode.test.js +++ /dev/null @@ -1,41 +0,0 @@ -import TreeNode from 'generic-components/treeNode/TreeNode'; -import React from 'react'; -import { mount } from 'enzyme'; - -describe('TreeNode', () => { - let treeNode; - - beforeEach(() => { - treeNode = mount().instance(); - }); - - - it('Should be invisible when created', () => { - // then - expect(treeNode.state['visible']).toEqual(false) - }); - - it('Should be visible when toggled', () => { - // given - expect(treeNode.state['visible']).toEqual(false) - - // when - treeNode.toggle(); - - // then - expect(treeNode.state['visible']).toEqual(true) - }); - - it('Should be invisible when double toggled', () => { - // given - expect(treeNode.state['visible']).toEqual(false); - - // when - treeNode.toggle(); - treeNode.toggle(); - - // then - expect(treeNode.state['visible']).toEqual(false); - }); - -}); diff --git a/test/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBar.test.js b/test/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBar.test.js deleted file mode 100644 index 25676b7..0000000 --- a/test/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBar.test.js +++ /dev/null @@ -1,35 +0,0 @@ -import React from 'react'; -import { mount } from 'enzyme'; -import {Provider} from 'react-redux' -import configureStore from 'redux-mock-store'; - -import GlobalAutoCompleteSearchBar from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBar.jsx' -import AutoCompleteSearchBar from 'generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.jsx'; -import { - globalAutoCompleteSearchBarActionTypes -} from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants.js'; - -describe('GlobalAutoCompleteSearchBarTests', () => { - const initValue = 'some random search text'; - const initialState = { - globalAutoCompleteSearchBarReducer: { - value: initValue - } - }; - const mockStore = configureStore(); - let store, wrapper; - - beforeEach( () => { - store = mockStore(initialState); - wrapper = mount(); - }) - - it('render search bar - visible', () => { - expect(wrapper).toHaveLength(1); // ensure the message bar is mounted - expect(wrapper.find(AutoCompleteSearchBar)).toHaveLength(1); // ensure the InlineMessage is mounted - }); - - it('props assigned properly', () => { - expect(wrapper.find(AutoCompleteSearchBar).props().value).toEqual(initValue); // check that the props match - }) -}) diff --git a/test/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.test.js b/test/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.test.js deleted file mode 100644 index 1078df6..0000000 --- a/test/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.test.js +++ /dev/null @@ -1,154 +0,0 @@ -import i18n from 'utils/i18n/i18n'; -import GlobalAutoCompleteSearchBarReducer from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.js'; -import { - globalAutoCompleteSearchBarActionTypes, - NO_MATCHES_FOUND -} from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants.js'; -import { - MESSAGE_LEVEL_WARNING, - MESSAGE_LEVEL_DANGER -} from 'utils/GlobalConstants.js'; - -describe('GlobalAutoCompleteSearchBarReducerTests', () => { - it('Action Type: SUGGESTION_FOUND', () => { - const suggestions = [ - { - entityType: 'some entity type', - value: 'selected value' - }, - { - entityType: 'some entity type', - value: 'other selected value' - } - ]; - const errMsg = 'some error message'; - const action = { - type: globalAutoCompleteSearchBarActionTypes.SUGGESTION_FOUND, - data: { - suggestions: suggestions, - errorMsg: errMsg - } - }; - let state = {}; - state = GlobalAutoCompleteSearchBarReducer(state, action); - expect(state).toEqual({ - suggestions: suggestions, - cachedSuggestions: suggestions, - feedbackMsgText: errMsg, - feedbackMsgSeverity: MESSAGE_LEVEL_DANGER - }); - }); - - it('Action Type: SUGGESTION_NOT_FOUND', () => { - const action = { - type: globalAutoCompleteSearchBarActionTypes.SUGGESTION_NOT_FOUND, - }; - let state = {}; - state = GlobalAutoCompleteSearchBarReducer(state, action); - expect(state).toEqual({ - suggestions: [{ text: i18n(NO_MATCHES_FOUND)}], - cachedSuggestions: [{ entityType: i18n(NO_MATCHES_FOUND)}], - feedbackMsgText: '', - feedbackMsgSeverity: '' - }); - }); - - it('Action Type: CLEAR_SUGGESTIONS_TEXT_FIELD', () => { - const action = { - type: globalAutoCompleteSearchBarActionTypes.CLEAR_SUGGESTIONS_TEXT_FIELD, - }; - let state = {}; - state = GlobalAutoCompleteSearchBarReducer(state, action); - expect(state).toEqual({ - suggestions: [], - cachedSuggestions: [], - value: '', - feedbackMsgText: '', - feedbackMsgSeverity: '', - clearSearchText: false - }); - }); - - it('Action Type: CLEAR_SUGGESTIONS', () => { - const action = { - type: globalAutoCompleteSearchBarActionTypes.CLEAR_SUGGESTIONS, - }; - let state = {}; - state = GlobalAutoCompleteSearchBarReducer(state, action); - expect(state).toEqual({ - suggestions: [] - }); - }); - - it('Action Type: SUGGESTION_CHANGED', () => { - const suggestionText = 'some suggestion text'; - const action = { - type: globalAutoCompleteSearchBarActionTypes.SUGGESTION_CHANGED, - data: suggestionText - }; - let state = {}; - state = GlobalAutoCompleteSearchBarReducer(state, action); - expect(state).toEqual({ - value: suggestionText, - feedbackMsgText: '', - feedbackMsgSeverity: '' - }); - }); - - it('Action Type: SUGGESTION_CLICKED', () => { - const suggestion = { - entityType: 'some entity type', - value: 'selected value' - }; - const action = { - type: globalAutoCompleteSearchBarActionTypes.SUGGESTION_CLICKED, - data: { - selectedSuggestion: suggestion - } - }; - let state = {}; - state = GlobalAutoCompleteSearchBarReducer(state, action); - expect(state).toEqual({ - selectedSuggestion: suggestion, - performPrepareVisualization: true, - feedbackMsgText: '', - feedbackMsgSeverity: '' - }); - }); - - it('Action Type: NETWORK_ERROR', () => { - const errMsg = 'some error message'; - const action = { - type: globalAutoCompleteSearchBarActionTypes.NETWORK_ERROR, - data: { - errorMsg: errMsg - } - }; - let state = {}; - state = GlobalAutoCompleteSearchBarReducer(state, action); - expect(state).toEqual({ - suggestions: [], - cachedSuggestions: [], - feedbackMsgText: errMsg, - feedbackMsgSeverity: MESSAGE_LEVEL_DANGER - }); - }); - - it('Action Type: SEARCH_WARNING_EVENT', () => { - const errMsg = 'some error message'; - const action = { - type: globalAutoCompleteSearchBarActionTypes.SEARCH_WARNING_EVENT, - data: { - errorMsg: errMsg - } - }; - let state = {}; - state = GlobalAutoCompleteSearchBarReducer(state, action); - expect(state).toEqual({ - suggestions: [], - cachedSuggestions: [], - feedbackMsgText: errMsg, - feedbackMsgSeverity: MESSAGE_LEVEL_WARNING - }); - }); -}) diff --git a/test/globalInlineMessageBar/GlobalInlineMessageBar.test.js b/test/globalInlineMessageBar/GlobalInlineMessageBar.test.js deleted file mode 100644 index 9dc2a28..0000000 --- a/test/globalInlineMessageBar/GlobalInlineMessageBar.test.js +++ /dev/null @@ -1,37 +0,0 @@ -import React from 'react'; -import { mount } from 'enzyme'; -import {Provider} from 'react-redux' -import configureStore from 'redux-mock-store'; - -import GlobalInlineMessageBar from 'app/globalInlineMessageBar/GlobalInlineMessageBar.jsx' -import { - MESSAGE_LEVEL_WARNING -} from 'utils/GlobalConstants.js' -import InlineMessage from 'generic-components/InlineMessage/InlineMessage.jsx'; - -describe('GlobalInlineMessageBarTests', () => { - const errMsg = 'some random message'; - const initialState = { - globalInlineMessageBar: { - feedbackMsgText: errMsg, - feedbackMsgSeverity: MESSAGE_LEVEL_WARNING - } - }; - const mockStore = configureStore(); - let store, wrapper; - - beforeEach( () => { - store = mockStore(initialState); - wrapper = mount(); - }) - - it('render message bar - visible', () => { - expect(wrapper).toHaveLength(1); // ensure the message bar is mounted - expect(wrapper.find(InlineMessage)).toHaveLength(1); // ensure the InlineMessage is mounted - }); - - it('props assigned properly', () => { - expect(wrapper.find(InlineMessage).props().level).toEqual(MESSAGE_LEVEL_WARNING); // check that the props match - expect(wrapper.find(InlineMessage).props().messageTxt).toEqual(errMsg); // check that the props match - }) -}) diff --git a/test/globalInlineMessageBar/GlobalInlineMessageBarAction.test.js b/test/globalInlineMessageBar/GlobalInlineMessageBarAction.test.js deleted file mode 100644 index 4def5ac..0000000 --- a/test/globalInlineMessageBar/GlobalInlineMessageBarAction.test.js +++ /dev/null @@ -1,42 +0,0 @@ -import configureStore from 'redux-mock-store'; -import thunk from 'redux-thunk'; - -import { - getSetGlobalMessageEvent, - getClearGlobalMessageEvent -} from 'app/globalInlineMessageBar/GlobalInlineMessageBarActions.js'; -import { - globalInlineMessageBarActionTypes -} from 'app/globalInlineMessageBar/GlobalInlineMessageBarConstants.js'; -import { - MESSAGE_LEVEL_WARNING -} from 'utils/GlobalConstants.js' - -describe('GlobalInlineMessageBarActionTests', () => { - it('getSetGlobalMessageEvent', () => { - const middlewares = [thunk]; - const mockStore = configureStore(middlewares); - const store = mockStore({}); - const msgText = 'some test msg'; - store.dispatch(getSetGlobalMessageEvent(msgText, MESSAGE_LEVEL_WARNING)); - const actions = store.getActions(); - expect(actions).toEqual([{ - type: globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE, - data: { - msgText: msgText, - msgSeverity: MESSAGE_LEVEL_WARNING - } - }]); - }); - - it('getClearGlobalMessageEvent', () => { - const middlewares = [thunk]; - const mockStore = configureStore(middlewares); - const store = mockStore({}); - store.dispatch(getClearGlobalMessageEvent()); - const actions = store.getActions(); - expect(actions).toEqual([{ - type: globalInlineMessageBarActionTypes.CLEAR_GLOBAL_MESSAGE - }]); - }); -}) diff --git a/test/globalInlineMessageBar/GlobalInlineMessageBarReducer.test.js b/test/globalInlineMessageBar/GlobalInlineMessageBarReducer.test.js deleted file mode 100644 index 62389b4..0000000 --- a/test/globalInlineMessageBar/GlobalInlineMessageBarReducer.test.js +++ /dev/null @@ -1,40 +0,0 @@ -import GlobalInlineMessageBarReducer from 'app/globalInlineMessageBar/GlobalInlineMessageBarReducer.js'; -import { - globalInlineMessageBarActionTypes -} from 'app/globalInlineMessageBar/GlobalInlineMessageBarConstants.js'; -import { - MESSAGE_LEVEL_WARNING -} from 'utils/GlobalConstants.js' - -describe('GlobalInlineMessageBarReducerTests', () => { - it('Action Type: SET_GLOBAL_MESSAGE', () => { - const action = { - type: globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE, - data: { - msgText: 'some error message here', - msgSeverity: MESSAGE_LEVEL_WARNING - } - }; - let state = {}; - state = GlobalInlineMessageBarReducer(state, action); - expect(state).toEqual({ - feedbackMsgText: action.data.msgText, - feedbackMsgSeverity: action.data.msgSeverity - }); - }); - - it('Action Type: CLEAR_GLOBAL_MESSAGE', () => { - const action = { - type: globalInlineMessageBarActionTypes.CLEAR_GLOBAL_MESSAGE - }; - let state = { - feedbackMsgText: 'some error message here', - feedbackMsgSeverity: MESSAGE_LEVEL_WARNING - }; - state = GlobalInlineMessageBarReducer(state, action); - expect(state).toEqual({ - feedbackMsgText: '', - feedbackMsgSeverity: '' - }); - }); -}) diff --git a/test/input/SelectInput.test.js b/test/input/SelectInput.test.js deleted file mode 100644 index a669361..0000000 --- a/test/input/SelectInput.test.js +++ /dev/null @@ -1,13 +0,0 @@ -import React from 'react'; -import { mount } from 'enzyme'; -import Select from 'react-select'; - -import SelectInput from 'generic-components/input/SelectInput.jsx'; - -describe('SelectInput Tests', () => { - it('render select input - visible', () => { - const select = mount( ); - expect(select).toHaveLength(1); // ensure the message bar is mounted - expect(select.find(Select)).toHaveLength(1); // ensure the InlineMessage is mounted - }); -}) diff --git a/test/input/ToggleInput.test.js b/test/input/ToggleInput.test.js deleted file mode 100644 index 80f0345..0000000 --- a/test/input/ToggleInput.test.js +++ /dev/null @@ -1,12 +0,0 @@ -import React from 'react'; -import { mount } from 'enzyme'; - -import ToggleInput from 'generic-components/input/ToggleInput.jsx'; - -describe('ToggleInput Tests', () => { - it('render toggle input - visible', () => { - const toggle = mount( ); - expect(toggle).toHaveLength(1); // ensure the message bar is mounted - expect(toggle.find('input')).toHaveLength(1); // ensure the InlineMessage is mounted - }); -}) diff --git a/test/networking/NetworkCalls.test.js b/test/networking/NetworkCalls.test.js deleted file mode 100644 index 373fbac..0000000 --- a/test/networking/NetworkCalls.test.js +++ /dev/null @@ -1,124 +0,0 @@ -import NetworkCalls from 'app/networking/NetworkCalls'; -import * as sinon from "sinon"; - -describe("Network Utils", () => { - - let suite; - - beforeEach(() => { - suite = {}; - suite.sandbox = sinon.createSandbox(); - }); - - afterEach(() => { - suite.sandbox.reset(); - }); - - describe('#fetchRequest', () => { - it('should fetch request', () => { - global.fetch = suite.sandbox.stub(); - - const then = suite.sandbox.stub(); - - fetch.returns({then}); - - NetworkCalls.fetchRequest("URL", "POST", "POST", "HEADER", "BODY"); - sinon.assert.calledOnce(then); - - expect(then.firstCall.args[0]({json: () => "json"})).toEqual("json"); - sinon.assert.calledOnce(fetch); - }); - }); - - describe('#fetchConfigurableViewRequest', () => { - it('fetch configurable request', () => { - const queryData = { - api: "api", - method: "method", - headers: "headers", - componentDataDescriptor: {object: "object"} - }; - - const fetchPromise = Promise.resolve(); - global.fetch = suite.sandbox.stub(); - - global.fetch - .withArgs(queryData.api, { - method: queryData.method, - headers: queryData.headers, - body: queryData.body - }) - .returns(fetchPromise); - - NetworkCalls.fetchConfigurableViewRequest(queryData); - - sinon.assert.calledWith(fetch, "http://localhost:api", { - method: queryData.method, - headers: queryData.headers, - credentials: "same-origin", - body: '{"object":"object"}' - }); - }); - }); - - describe('#fetchRequestObj', () => { - it('fetch request object', () => { - - const fetchPromise = Promise.resolve(); - global.fetch = suite.sandbox.stub(); - const url = 'url'; - - global.fetch - .withArgs(url, { - method: 'GET', - headers: 'POST_HEADER', - body: 'BODY' - - }) - .returns(fetchPromise); - - NetworkCalls.fetchRequestObj(url, "GET", "POST_HEADER", "BODY"); - - sinon.assert.calledWith(fetch, url, { - credentials: 'same-origin', - method: "GET", - headers: "POST_HEADER", - body: "BODY" - }); - }); - }); - - describe('#getRequest', () => { - it("should fetch any request", () => { - const json = suite.sandbox.stub(); - const fetchPromise = Promise.resolve({json}); - global.fetch = suite.sandbox.stub(); - - global.fetch - .withArgs('URL', { - credentials: 'same-origin', - method: 'GET' - }) - .returns(fetchPromise); - - NetworkCalls.getRequest("URL", "GET"); - - return fetchPromise.then(() => { - sinon.assert.calledOnce(json); - }); - }); - }); - - describe('#genericRequest', () => { - it('should fetch any generic request', () => { - global.fetch = suite.sandbox.stub(); - const then = suite.sandbox.stub(); - fetch.returns({then}); - NetworkCalls.genericRequest("localhost", "/relativeUrl", "GET"); - - expect(then.firstCall.args[0]({json: () => "d"})).toEqual("d"); - - sinon.assert.calledOnce(fetch); - }); - }); -}); diff --git a/test/networking/NetworkUtil.test.js b/test/networking/NetworkUtil.test.js deleted file mode 100644 index 1743813..0000000 --- a/test/networking/NetworkUtil.test.js +++ /dev/null @@ -1,22 +0,0 @@ -import {getTSUIElasticSearchQueryString} from 'app/networking/NetworkUtil'; - -describe("Network Utils", () => { - describe('#getTSUIElasticSearchQueryString', () => { - it('should return query body', () => { - const query = "query"; - const response = getTSUIElasticSearchQueryString(query); - expect(response).toEqual({"maxResults": "10", "queryStr": "query"}); - }); - - it('should return partial request query', () => { - const query = ""; - const response = getTSUIElasticSearchQueryString(query); - expect(response).toEqual({"maxResults": "10", "queryStr": ""}); - }); - - it('should be truthy', () => { - const query = ""; - expect(getTSUIElasticSearchQueryString(query)).toBeTruthy(); - }) - }); -}); diff --git a/test/tierSupport/SelectedNodeDetails.test.js b/test/tierSupport/SelectedNodeDetails.test.js deleted file mode 100644 index 5f97626..0000000 --- a/test/tierSupport/SelectedNodeDetails.test.js +++ /dev/null @@ -1,141 +0,0 @@ -import React from 'react'; -import { shallow, mount } from 'enzyme'; -import {Provider} from 'react-redux' -import configureStore from 'redux-mock-store'; -import Table from 'react-bootstrap/lib/Table'; - -import ConnectedSelectedNodeDetails, { SelectedNodeDetails } from 'app/tierSupport/selectedNodeDetails/SelectedNodeDetails.jsx'; -import { SELECTED_NODE_TABLE_COLUMN_NAMES } from 'app/tierSupport/selectedNodeDetails/SelectedNodeDetailsConstants.js'; -import LaunchInContext from 'app/tierSupport/launchExternalResource/LaunchExternalResource.jsx'; - -describe('SelectedNodeDetails - Shallow render of component', () => { - let wrapper; - const nodeTypeProp = 'VNF'; - const uidProp = 'SomeValidUIDName'; - const nodeDataProp = { - 'interface-role': 'MPLS', - 'in-maint': 'false', - 'interface-type': 'WAN', - 'port-description': 'MPLS port on 10_NSG16_location4', - 'resource-version': '123456789', - 'interface-name': '10_port1_location4', - 'uri': 'network/pnfs/pnf/10_NSG14_location4/p-interfaces/p-interface/10_port1_location4' - }; - - beforeEach( () => { - wrapper = shallow( - ); - }) - - it('Render basic component', () => { - expect(wrapper.length).toEqual(1); - }); - - it('Verify node type is displayed as a header', () => { - expect(wrapper.contains(

    {nodeTypeProp}

    )).toBe(true); - expect(wrapper.find('h2')).toHaveLength(1); - }); - - it('Verify uid is displayed', () => { - expect(wrapper.contains({uidProp} )).toBe(true); - }); - - it('Verify node data table is displayed', () => { - // verify table has a row for each node data prop plus one row for the column headers - expect(wrapper.find(Table)).toHaveLength(1); - expect(wrapper.find(Table).props().bsClass).toEqual('ts-selected-node-table'); - expect(wrapper.find(Table).children()).toHaveLength(2); // thead and tbody - - // validate the table header content - expect(wrapper.find('thead')).toHaveLength(1); - let cellClassName; - for (let index = 1; index <= SELECTED_NODE_TABLE_COLUMN_NAMES.length; index++) { - cellClassName = (index % 2 ? 'left-column-cell' : 'right-column-cell'); - expect(wrapper.contains( - {SELECTED_NODE_TABLE_COLUMN_NAMES[index-1]} - )).toBe(true); - } - - // validate the table body content - expect(wrapper.find('tbody')).toHaveLength(1); - expect(wrapper.find('tbody').children()).toHaveLength(7); // 1 row for each of the 7 properties - for (let prop in nodeDataProp) { - expect(wrapper.contains( - {prop} - )).toBe(true); - expect(wrapper.contains( - {nodeDataProp[prop]} - )).toBe(true); - } - }); -}) - -describe('SelectedNodeDetails - Shallow render of component with no node data', () => { - let wrapper; - const nodeTypeProp = 'VNF'; - const uidProp = 'SomeValidUIDName'; - const nodeDataProp = {}; - - beforeEach( () => { - wrapper = shallow( - ); - }) - - it('Render basic component', () => { - expect(wrapper.length).toEqual(1); - }); - - it('Verify node data table is hidden', () => { - // verify table is hidden - expect(wrapper.find(Table)).toHaveLength(1); - expect(wrapper.find(Table).props().bsClass).toEqual('hidden'); - }); -}) - -describe('SelectedNodeDetails - Render React Component (wrapped in )', () => { - const initialState = { - tierSupport: { - launchExternalResourceReducer: { - externalResourcePayload: {} - }, - selectedNodeDetails: { - nodeType: 'VNF', - uid: 'AAI/CLYMR/000509/SD_WAN', - nodeData: { - 'interface-role': 'MPLS', - 'in-maint': 'false', - 'interface-type': 'WAN', - 'port-description': 'MPLS port on 10_NSG16_location4', - 'resource-version': '123456789', - 'interface-name': '10_port1_location4', - 'uri': 'network/pnfs/pnf/10_NSG14_location4/p-interfaces/p-interface/10_port1_location4' - } - } - } - }; - const mockStore = configureStore(); - let store, wrapper; - - beforeEach( () => { - store = mockStore(initialState); - wrapper = mount(); - }) - - it('Render the connected component', () => { - expect(wrapper.find(ConnectedSelectedNodeDetails).length).toEqual(1); - }); - - it('Validate props from store', () => { - expect(wrapper.find(SelectedNodeDetails).props().uid).toEqual(initialState.tierSupport.selectedNodeDetails.uid); - expect(wrapper.find(SelectedNodeDetails).props().nodeType).toEqual(initialState.tierSupport.selectedNodeDetails.nodeType); - expect(wrapper.find(SelectedNodeDetails).props().nodeData).toEqual(initialState.tierSupport.selectedNodeDetails.nodeData); - }); -}) diff --git a/test/tierSupport/SelectedNodeDetailsReducer.test.js b/test/tierSupport/SelectedNodeDetailsReducer.test.js deleted file mode 100644 index 238d21c..0000000 --- a/test/tierSupport/SelectedNodeDetailsReducer.test.js +++ /dev/null @@ -1,248 +0,0 @@ -import SelectedNodeDetailsReducer from 'app/tierSupport/selectedNodeDetails/SelectedNodeDetailsReducer.js'; -import {tierSupportActionTypes} from 'app/tierSupport/TierSupportConstants.js'; -import { - globalAutoCompleteSearchBarActionTypes -} from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants.js'; - -describe('SelectedNodeDetails - Reducer Tests', () => { - it('Action Type: TS_NODE_SEARCH_RESULTS', () => { - const action = { - type: tierSupportActionTypes.TS_NODE_SEARCH_RESULTS, - data: { - nodes: [ - { - 'id': 'AAI/CLYMR/000509/SD_WAN', - 'itemType': 'service-instance', - 'itemNameKey': 'service-instance.AAI/SPRKY/000509/SD_WAN', - 'itemNameValue': 'AAI/SPRKY/000509/SD_WAN', - 'itemProperties': { - 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN', - 'resource-version':'1508078039815' - }, - 'itemIntegrity' : { - 'entityId' : 'AEEhny_vnf1_under_fw-si1', - 'entityType' : 'vnf', - 'entityLink' : 'cloud-infrastr084-1377-4f49-9c72-f0_location2', - 'initialTimestamp' :'2017-11-13T16:58:01Z', - 'latestValidationTimestamp':'2017-11-13T16:58:01Z', - 'resourceVersion':'1510592264096', - 'violations': [] - }, - 'nodeMeta': { - 'className': 'selectedSearchedNodeClass', - 'nodeDebug': null, - 'selfLinkResponseTimeInMs': 628, - 'relationshipNode': false, - 'searchTarget': true, - 'enrichableNode': false, - 'nodeValidated': true, - 'nodeIssue': false, - 'maxAltitude': 4, - 'nodeType': 'serviceInstance', - 'nodeLabel1':'service-instance', - 'nodeLabel2':'AAI/SPRKY/000509/SD_WAN' - }, - 'rootNode' : false - } - ] - } - }; - let state = { - nodeType: '', - uid: '', - nodeData: {} - }; - state = SelectedNodeDetailsReducer(state, action); - expect(state).toEqual({ - nodeType: action['data']['nodes'][0]['itemType'], - uid: action['data']['nodes'][0]['itemNameValue'], - nodeData: action['data']['nodes'][0]['itemProperties'] - }); - }); - - it('Action Type: TS_NODE_SEARCH_RESULTS - searchTarget === false', () => { - const action = { - type: tierSupportActionTypes.TS_NODE_SEARCH_RESULTS, - data: { - nodes: [ - { - 'id': 'AAI/CLYMR/000509/SD_WAN', - 'itemType': 'service-instance', - 'itemNameKey': 'service-instance.AAI/SPRKY/000509/SD_WAN', - 'itemNameValue': 'AAI/SPRKY/000509/SD_WAN', - 'itemProperties': { - 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN', - 'resource-version':'1508078039815' - }, - 'itemIntegrity' : { - 'entityId' : 'AEEhny_vnf1_under_fw-si1', - 'entityType' : 'vnf', - 'entityLink' : 'cloud-infrastr084-1377-4f49-9c72-f0_location2', - 'initialTimestamp' :'2017-11-13T16:58:01Z', - 'latestValidationTimestamp':'2017-11-13T16:58:01Z', - 'resourceVersion':'1510592264096', - 'violations': [] - }, - 'nodeMeta': { - 'className': 'selectedSearchedNodeClass', - 'nodeDebug': null, - 'selfLinkResponseTimeInMs': 628, - 'relationshipNode': false, - 'searchTarget': false, - 'enrichableNode': false, - 'nodeValidated': true, - 'nodeIssue': false, - 'maxAltitude': 4, - 'nodeType': 'serviceInstance', - 'nodeLabel1':'service-instance', - 'nodeLabel2':'AAI/SPRKY/000509/SD_WAN' - }, - 'rootNode' : false - } - ] - } - }; - let state = { - nodeType: 'Complex', - uid: 'ABC', - nodeData: { - 'service-instance-id': 'blah/blah/blah', - 'resource-version':'123456' - } - }; - state = SelectedNodeDetailsReducer(state, action); - expect(state).toEqual({ - nodeType: '', - uid: '', - nodeData: {} - }); - }); - - it('Action Type: TS_GRAPH_NODE_SELECTED', () => { - const action = { - type: tierSupportActionTypes.TS_GRAPH_NODE_SELECTED, - data: { - itemProperties: { - 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN', - 'resource-version':'1508078039815' - }, - itemType: 'Complex', - itemNameValue: '123456' - } - }; - let state = { - nodeType: '', - uid: '', - nodeData: {} - }; - state = SelectedNodeDetailsReducer(state, action); - expect(state).toEqual({ - nodeType: action['data']['itemType'], - uid: action['data']['itemNameValue'], - nodeData: action['data']['itemProperties'] - }); - }); - - it('Action Type: TIER_SUPPORT_NETWORK_ERROR', () => { - const action = { - type: tierSupportActionTypes.TIER_SUPPORT_NETWORK_ERROR, - }; - let state = { - nodeType: 'Complex', - uid: '12345', - nodeData: { - 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN', - 'resource-version':'1508078039815' - } - }; - state = SelectedNodeDetailsReducer(state, action); - expect(state).toEqual({ - nodeType: '', - uid: '', - nodeData: {} - }); - }); - - it('Action Type: TIER_SUPPORT_CLEAR_DATA', () => { - const action = { - type: tierSupportActionTypes.TIER_SUPPORT_CLEAR_DATA, - }; - let state = { - nodeType: 'Complex', - uid: '12345', - nodeData: { - 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN', - 'resource-version':'1508078039815' - } - }; - state = SelectedNodeDetailsReducer(state, action); - expect(state).toEqual({ - nodeType: '', - uid: '', - nodeData: {} - }); - }); - - it('Action Type: TS_NODE_SEARCH_NO_RESULTS', () => { - const action = { - type: tierSupportActionTypes.TS_NODE_SEARCH_NO_RESULTS, - }; - let state = { - nodeType: 'Complex', - uid: '12345', - nodeData: { - 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN', - 'resource-version':'1508078039815' - } - }; - state = SelectedNodeDetailsReducer(state, action); - expect(state).toEqual({ - nodeType: '', - uid: '', - nodeData: {} - }); - }); - - it('Action Type: SEARCH_WARNING_EVENT', () => { - const action = { - type: globalAutoCompleteSearchBarActionTypes.SEARCH_WARNING_EVENT, - }; - let state = { - nodeType: 'Complex', - uid: '12345', - nodeData: { - 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN', - 'resource-version':'1508078039815' - } - }; - state = SelectedNodeDetailsReducer(state, action); - expect(state).toEqual({ - nodeType: '', - uid: '', - nodeData: {} - }); - }); - - it('Invalid Action Type', () => { - const action = { - type: 'Nonexistent Action Type', - }; - let state = { - nodeType: 'Complex', - uid: '12345', - nodeData: { - 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN', - 'resource-version':'1508078039815' - } - }; - state = SelectedNodeDetailsReducer(state, action); - expect(state).toEqual({ - nodeType: 'Complex', - uid: '12345', - nodeData: { - 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN', - 'resource-version':'1508078039815' - } - }); - }); -}) diff --git a/test/tierSupport/TierSupportActions.test.js b/test/tierSupport/TierSupportActions.test.js deleted file mode 100644 index 62485ee..0000000 --- a/test/tierSupport/TierSupportActions.test.js +++ /dev/null @@ -1,177 +0,0 @@ -import configureStore from 'redux-mock-store'; -import thunk from 'redux-thunk' -import { - onNodeDetailsChange, - splitPaneResize, - onNodeMenuChange, - clearVIData, - setNotificationText -} from 'app/tierSupport/TierSupportActions.js'; -import { - tierSupportActionTypes -} from 'app/tierSupport/TierSupportConstants.js'; -import { - MESSAGE_LEVEL_WARNING -} from 'utils/GlobalConstants.js'; -import { - globalInlineMessageBarActionTypes -} from 'app/globalInlineMessageBar/GlobalInlineMessageBarConstants.js'; - -describe('TierSupportActionTests', () => { - it('onNodeDetailsChange', () => { - const newDetails = { - id: '7352312c7bfa814c3071a803d98c5b670952765974876e55ef954e0f8a930b1c', - itemType: 'complex', - nodeMeta: { - nodeLabel1: 'Artic', - nodeValidated: false, - nodeLocation: 'bottom' - }, - rootNode: false, - index: 2, - }; - const middlewares = [thunk]; - const mockStore = configureStore(middlewares); - const store = mockStore({ tierSupportReducer: {} }); - store.dispatch(onNodeDetailsChange(newDetails)); - const actions = store.getActions(); - expect(actions).toEqual([{ - type: tierSupportActionTypes.TS_GRAPH_NODE_SELECTED, - data: newDetails - }]); - }); - - it('splitPaneResize', () => { - const initialLoad = { - test: 'message' - }; - const middlewares = [thunk]; - const mockStore = configureStore(middlewares); - const store = mockStore({ tierSupportReducer: {} }); - store.dispatch(splitPaneResize(initialLoad)); - const actions = store.getActions(); - expect(actions).toEqual([{ - type: tierSupportActionTypes.SPLIT_PANE_RESIZE, - data: initialLoad - }]); - }); - - it('onNodeMenuChange', () => { - const selectedMenu = { - test: 'menuData' - }; - const middlewares = [thunk]; - const mockStore = configureStore(middlewares); - const store = mockStore({ tierSupportReducer: {} }); - store.dispatch(onNodeMenuChange(selectedMenu)); - const actions = store.getActions(); - expect(actions).toEqual([{ - type: tierSupportActionTypes.TS_GRAPH_NODE_MENU_SELECTED, - data: selectedMenu - }]); - }); - - it('clearVIData', () => { - const middlewares = [thunk]; - const mockStore = configureStore(middlewares); - const store = mockStore({ tierSupportReducer: {} }); - store.dispatch(clearVIData()); - const actions = store.getActions(); - expect(actions).toEqual([{ - type: tierSupportActionTypes.TIER_SUPPORT_CLEAR_DATA - }]); - }); - // - // it('fetchSelectedNodeElement - no results', () => { - // const middlewares = [thunk]; - // const mockStore = configureStore(middlewares); - // const store = mockStore({ tierSupportReducer: {} }); - // const nodes = [ - // { - // id: '7352312c7bfa814c3071a803d98c5b670952765974876e55ef954e0f8a930b1c', - // itemType: 'complex', - // nodeMeta: { - // className: 'selectedSearchedNodeClass', - // nodeLabel1: 'Artic', - // nodeValidated: false, - // nodeLocation: 'bottom' - // }, - // rootNode: false, - // index: 2 - // }, - // { - // id: '3899453d98c5b670952765974876e55ef954e0f8a930b1c', - // itemType: 'generic-vnf', - // nodeMeta: { - // className: 'someOtherClassName', - // nodeLabel1: 'Artic', - // nodeValidated: false, - // nodeLocation: 'bottom' - // }, - // rootNode: false, - // index: 1 - // } - // ]; - // const expectedActions = [ - // { - // type: tierSupportActionTypes.TS_NODE_SEARCH_RESULTS, - // data: { - // nodes: nodes - // } - // }, - // { - // type: tierSupportActionTypes.TS_GRAPH_NODE_SELECTED, - // data: nodes[0] - // } - // ]; - // - // console.log(nodes); - // - // let fetchRequestCallback = () => { - // const results = { - // nodes: nodes - // }; - // let init = { status: 200 }; - // let myBlob = new Blob(); - // let response = new Response(); - // return new Promise((resolve, reject) => { - // resolve(response); - // }); - // }; - // return store.dispatch(fetchSelectedNodeElement(fetchRequestCallback)) - // .then( () => { - // const actions = store.getActions(); - // expect(actions).toEqual(expectedActions); - // }); - // }); - - it('setNotificationText', () => { - const middlewares = [thunk]; - const mockStore = configureStore(middlewares); - const store = mockStore({ tierSupportReducer: {} }); - const msgText = 'some test text'; - const msgSeverity = MESSAGE_LEVEL_WARNING; - store.dispatch(setNotificationText(msgText, msgSeverity)); - const actions = store.getActions(); - expect(actions).toEqual([{ - type: globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE, - data: { - msgText: msgText, - msgSeverity: msgSeverity - } - }]); - }); - - it('Clear notification text with setNotificationText', () => { - const middlewares = [thunk]; - const mockStore = configureStore(middlewares); - const store = mockStore({ tierSupportReducer: {} }); - const msgText = ''; - const msgSeverity = MESSAGE_LEVEL_WARNING; - store.dispatch(setNotificationText(msgText, msgSeverity)); - const actions = store.getActions(); - expect(actions).toEqual([{ - type: globalInlineMessageBarActionTypes.CLEAR_GLOBAL_MESSAGE - }]); - }); -}) diff --git a/test/tierSupport/TierSupportReducer.test.js b/test/tierSupport/TierSupportReducer.test.js deleted file mode 100644 index 9825a06..0000000 --- a/test/tierSupport/TierSupportReducer.test.js +++ /dev/null @@ -1,206 +0,0 @@ -import TierSupportReducer from 'app/tierSupport/TierSupportReducer.js'; -import ForceDirectedGraph from 'generic-components/graph/ForceDirectedGraph.jsx'; -import { - tierSupportActionTypes, - TSUI_GRAPH_MENU_NODE_DETAILS -} from 'app/tierSupport/TierSupportConstants.js'; -import { - MESSAGE_LEVEL_WARNING, - MESSAGE_LEVEL_DANGER -} from 'utils/GlobalConstants.js'; -import { - globalAutoCompleteSearchBarActionTypes -} from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants.js'; - -describe('TierSupportReducerTests', () => { - it('Action Type: TS_NODE_SEARCH_RESULTS', () => { - ForceDirectedGraph.graphCounter = 0; // ensuring counter is at zero after previous tests - const action = { - type: tierSupportActionTypes.TS_NODE_SEARCH_RESULTS, - data: { - nodes: [ - { - nodeMeta: { - searchTarget: true - }, - itemProperties: 'someProperty' - } - ], - links: ['link', 'information'], - graphMeta: { graph: 'meta' } - } - }; - let graphData = ForceDirectedGraph.generateNewProps(action.data.nodes, action.data.links, - action.data.graphMeta); - ForceDirectedGraph.graphCounter = 0; // ensuring counter is at zero after previous statement - let state = {}; - state = TierSupportReducer(state, action); - expect(state.tierSupportReducer).toEqual({ - forceDirectedGraphRawData: graphData, - feedbackMsgText: '', - feedbackMsgSeverity: '' - }); - }); - - it('Action Type: TS_GRAPH_NODE_MENU_SELECTED', () => { - const action = { - type: tierSupportActionTypes.TS_GRAPH_NODE_MENU_SELECTED, - data: { - attr1: 'someValue', - attr2: 'someOterValue' - } - }; - let state = {}; - state = TierSupportReducer(state, action); - expect(state.tierSupportReducer).toEqual({ - graphNodeSelectedMenu: action.data - }); - }); - - it('Action Type: TS_NODE_SEARCH_NO_RESULTS', () => { - ForceDirectedGraph.graphCounter = 0; // ensuring counter is at zero after previous tests - let emptyNodesAndLinksNoResults = { - graphCounter: 1, - graphMeta: {}, - linkDataArray: [], - nodeDataArray: [] - }; - const action = { - type: tierSupportActionTypes.TS_NODE_SEARCH_NO_RESULTS, - data: { - errorMsg: 'some error message' - } - }; - let state = {}; - state = TierSupportReducer(state, action); - expect(state.tierSupportReducer).toEqual({ - forceDirectedGraphRawData: emptyNodesAndLinksNoResults, - graphNodeSelectedMenu: TSUI_GRAPH_MENU_NODE_DETAILS, - feedbackMsgText: action.data.errorMsg, - feedbackMsgSeverity: MESSAGE_LEVEL_WARNING - }); - }); - - it('Action Type: TIER_SUPPORT_NETWORK_ERROR', () => { - ForceDirectedGraph.graphCounter = 0; // ensuring counter is at zero after previous tests - let emptyNodesAndLinksNoResults = { - graphCounter: 1, - graphMeta: {}, - linkDataArray: [], - nodeDataArray: [] - }; - const action = { - type: tierSupportActionTypes.TIER_SUPPORT_NETWORK_ERROR, - data: { - errorMsg: 'some error message' - } - }; - let state = {}; - state = TierSupportReducer(state, action); - expect(state.tierSupportReducer).toEqual({ - forceDirectedGraphRawData: emptyNodesAndLinksNoResults, - graphNodeSelectedMenu: TSUI_GRAPH_MENU_NODE_DETAILS, - feedbackMsgText: action.data.errorMsg, - feedbackMsgSeverity: MESSAGE_LEVEL_DANGER - }); - }); - - it('Action Type: TIER_SUPPORT_CLEAR_DATA', () => { - ForceDirectedGraph.graphCounter = 0; // ensuring counter is at zero after previous tests - let emptyNodesAndLinksNoResults = { - graphCounter: 1, - graphMeta: {}, - linkDataArray: [], - nodeDataArray: [] - }; - const action = { - type: tierSupportActionTypes.TIER_SUPPORT_CLEAR_DATA - }; - let state = {}; - state = TierSupportReducer(state, action); - expect(state.tierSupportReducer).toEqual({ - forceDirectedGraphRawData: emptyNodesAndLinksNoResults, - graphNodeSelectedMenu: TSUI_GRAPH_MENU_NODE_DETAILS, - feedbackMsgText: '', - feedbackMsgSeverity: '' - }); - }); - - it('Action Type: TS_GRAPH_NODE_SELECTED', () => { - const action = { - type: tierSupportActionTypes.TS_GRAPH_NODE_SELECTED, - data: 'some action data' - }; - let state = {}; - state = TierSupportReducer(state, action); - expect(state.tierSupportReducer).toEqual({ - nodeData: action.data - }); - }); - - it('Action Type: TIER_SUPPORT_ACTIVATE_BUSY_FEEDBACK', () => { - const action = { - type: tierSupportActionTypes.TIER_SUPPORT_ACTIVATE_BUSY_FEEDBACK, - }; - let state = {}; - state = TierSupportReducer(state, action); - expect(state.tierSupportReducer).toEqual({ - enableBusyFeedback: true - }); - }); - - it('Action Type: TIER_SUPPORT_DISABLE_BUSY_FEEDBACK', () => { - const action = { - type: tierSupportActionTypes.TIER_SUPPORT_DISABLE_BUSY_FEEDBACK, - }; - let state = {}; - state = TierSupportReducer(state, action); - expect(state.tierSupportReducer).toEqual({ - enableBusyFeedback: false - }); - }); - - it('Action Type: SEARCH_WARNING_EVENT', () => { - ForceDirectedGraph.graphCounter = 0; // ensuring counter is at zero after previous tests - let emptyNodesAndLinksNoResults = { - graphCounter: 1, - graphMeta: {}, - linkDataArray: [], - nodeDataArray: [] - }; - const action = { - type: globalAutoCompleteSearchBarActionTypes.SEARCH_WARNING_EVENT, - data: { - errorMsg: 'some warning msg' - } - }; - let state = {}; - state = TierSupportReducer(state, action); - expect(state.tierSupportReducer).toEqual({ - forceDirectedGraphRawData: emptyNodesAndLinksNoResults, - graphNodeSelectedMenu: TSUI_GRAPH_MENU_NODE_DETAILS - }); - }); - - it('Action Type: TS_OVERLAY_NETWORK_CALLBACK_RESPONSE_RECEIVED', () => { - const action = { - type: tierSupportActionTypes.TS_OVERLAY_NETWORK_CALLBACK_RESPONSE_RECEIVED, - data: { - curData: { - attr1: 'value1', - attr2: 'value2' - }, - paramName: 'attr2', - overlayData: 'someValue2' - } - }; - let state = {}; - state = TierSupportReducer(state, action); - expect(state.tierSupportReducer).toEqual({ - nodeData: { - attr1: 'value1', - attr2: 'someValue2' - } - }); - }); -}) diff --git a/test/vnfSearch/VnfSearch.test.js b/test/vnfSearch/VnfSearch.test.js deleted file mode 100644 index 3875543..0000000 --- a/test/vnfSearch/VnfSearch.test.js +++ /dev/null @@ -1,49 +0,0 @@ -import React from 'react'; -import { shallow, mount } from 'enzyme'; -import {Provider} from 'react-redux'; -import configureStore from 'redux-mock-store'; - -import ConnectedVnfSearch, { vnfSearch } from 'app/vnfSearch/VnfSearch.jsx'; - -describe('VnfSearch - Shallow render of component', () => { - let wrapper; - const vnfFilters = {}; - const vnfVisualizationPanelClass = 'collapsible-panel-main-panel'; - const unifiedFilterValues = {}; - - beforeEach( () => { - wrapper = shallow( - - ); - }) - - it('Render basic component', () => { - expect(wrapper.length).toEqual(1); - }); -}) -// -// describe('VnfSearch - Render React Component (wrapped in )', () => { -// const initialState = { -// vnfSearch: {} -// }; -// const mockStore = configureStore(); -// let store, wrapper; -// -// beforeEach( () => { -// store = mockStore(initialState); -// wrapper = mount(); -// }) -// -// it('Render the connected component', () => { -// expect(wrapper.find(ConnectedVnfSearch).length).toEqual(1); -// }); -// -// it('Validate props from store', () => { -// expect(wrapper.find(VnfSearchNfRoleVisualization).props().enableBusyFeedback).toEqual(initialState.vnfSearch.enableBusyFeedback); -// expect(wrapper.find(VnfSearchNfRoleVisualization).props().processedNfRoleCountChartData).toEqual(initialState.vnfSearch.processedNfRoleCountChartData); -// }); -// }) diff --git a/test/vnfSearch/VnfSearchActions.test.js b/test/vnfSearch/VnfSearchActions.test.js deleted file mode 100644 index e1c3733..0000000 --- a/test/vnfSearch/VnfSearchActions.test.js +++ /dev/null @@ -1,215 +0,0 @@ -import configureStore from 'redux-mock-store'; -import thunk from 'redux-thunk' -import fetchMock from 'fetch-mock'; - -import { - processVnfFilterPanelCollapse, - clearVnfSearchData, - setNotificationText, - processVnfVisualizationsOnFilterChange -} from 'app/vnfSearch/VnfSearchActions.js'; -import { - vnfActionTypes, - CHART_PROV_STATUS, - CHART_ORCH_STATUS, - CHART_NF_TYPE, - CHART_NF_ROLE, - TOTAL_VNF_COUNT, - VNF_FILTER_EMPTY_RESULT -} from 'app/vnfSearch/VnfSearchConstants.js'; -import { globalInlineMessageBarActionTypes } from 'app/globalInlineMessageBar/GlobalInlineMessageBarConstants.js'; -import { ERROR_RETRIEVING_DATA } from 'app/networking/NetworkConstants.js'; - -describe('VnfSearchAction - Action Tests', () => { - it('Action: processVnfFilterPanelCollapse - open', () => { - const result = processVnfFilterPanelCollapse(true); - expect(result).toEqual({ - type: vnfActionTypes.VNF_FILTER_PANEL_TOGGLED, - data: { - vnfVisualizationPanelClass: 'collapsible-panel-main-panel vertical-filter-panel-is-open' - } - }); - }); - - it('Action: processVnfFilterPanelCollapse - close', () => { - const result = processVnfFilterPanelCollapse(false); - expect(result).toEqual({ - type: vnfActionTypes.VNF_FILTER_PANEL_TOGGLED, - data: { - vnfVisualizationPanelClass: 'collapsible-panel-main-panel' - } - }); - }); - - it('Action: clearVnfSearchData', () => { - const result = clearVnfSearchData(); - expect(result).toEqual({ - type: vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED, - data: { - count: '', - provStatusData: CHART_PROV_STATUS.emptyData, - orchStatusData: CHART_ORCH_STATUS.emptyData, - nfTypeData: CHART_NF_TYPE.emptyData, - nfRoleData: CHART_NF_ROLE.emptyData - } - }); - }); - - it('Action: setNotificationText - with message', () => { - const middlewares = [thunk]; - const mockStore = configureStore(middlewares); - const store = mockStore({ vnfSearch: {} }); - store.dispatch(setNotificationText('test error message', 'WARNING')); - const actions = store.getActions(); - expect(actions).toEqual([{ - type: globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE, - data: { - msgText: 'test error message', - msgSeverity: 'WARNING' - } - }]); - }); - - it('Action: processVnfVisualizationsOnFilterChange - data for filter values', () => { - const middlewares = [thunk]; - const mockStore = configureStore(middlewares); - const store = mockStore({ vnfSearch: {} }); - const filterValueMap = { - 1: 'Running', - 2: 'Junk', - 7: 'Blah', - 8: 'Doh' - }; - const expectedActions = [ - { type: vnfActionTypes.VNF_ACTIVATE_BUSY_FEEDBACK }, - { type: globalInlineMessageBarActionTypes.CLEAR_GLOBAL_MESSAGE }, - { - type: vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED, - data: { - count: 10, - provStatusData: { - values: [ - { x: 'junk', y: 10 } - ] - }, - orchStatusData: { - values: [ - { x: 'running', y: 10 } - ] - }, - nfTypeData: { - values: [ - { x: 'doh', y: 10 } - ] - }, - nfRoleData: { - values: [ - { x: 'blah', y: 10 } - ] - } - } - }, - { type: vnfActionTypes.VNF_DISABLE_BUSY_FEEDBACK } - ]; - fetchMock.mock('*', { - "total": 10, - "aggregations":{ - "nf-role":[{"doc_count":10,"key":"blah"}], - "nf-type":[{"doc_count":10,"key":"doh"}], - "prov-status":[{"doc_count":10,"key":"junk"}], - "orchestration-status":[{"doc_count":10,"key":"running"}] - } - }); - - return store.dispatch(processVnfVisualizationsOnFilterChange(filterValueMap)) - .then( () => { - const actions = store.getActions(); - expect(actions).toEqual(expectedActions); - fetchMock.restore(); - }); - }); - - it('Action: processVnfVisualizationsOnFilterChange - no data for filter values', () => { - const middlewares = [thunk]; - const mockStore = configureStore(middlewares); - const store = mockStore({ vnfSearch: {} }); - const filterValueMap = { - 1: 'Running', - 2: 'Junk', - 7: '', - 8: 'Doh' - }; - const expectedActions = [ - { type: vnfActionTypes.VNF_ACTIVATE_BUSY_FEEDBACK }, - { type: globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE, - data: { msgSeverity: "warning", msgText: VNF_FILTER_EMPTY_RESULT } - }, - { - type: vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED, - data: { - count: TOTAL_VNF_COUNT.emptyData, - provStatusData: CHART_PROV_STATUS.emptyData, - orchStatusData: CHART_ORCH_STATUS.emptyData, - nfTypeData: CHART_NF_TYPE.emptyData, - nfRoleData: CHART_NF_ROLE.emptyData - } - }, - { type: vnfActionTypes.VNF_DISABLE_BUSY_FEEDBACK } - ]; - fetchMock.mock('*', { - "total": 0, - "aggregations":{ - "nf-role":[], - "nf-type":[], - "prov-status":[], - "orchestration-status":[] - } - }); - - return store.dispatch(processVnfVisualizationsOnFilterChange(filterValueMap)) - .then( () => { - const actions = store.getActions(); - expect(actions).toEqual(expectedActions); - fetchMock.restore(); - }); - }); - - it('Action: processVnfVisualizationsOnFilterChange - network error', () => { - const middlewares = [thunk]; - const mockStore = configureStore(middlewares); - const store = mockStore({ vnfSearch: {} }); - const filterValueMap = { - 1: 'Running', - 2: 'Junk', - 7: 'Blah', - 8: 'Doh' - }; - const expectedActions = [ - { type: vnfActionTypes.VNF_ACTIVATE_BUSY_FEEDBACK }, - { type: vnfActionTypes.VNF_DISABLE_BUSY_FEEDBACK }, - { - type: vnfActionTypes.VNF_NETWORK_ERROR, - data: { errorMsg: ERROR_RETRIEVING_DATA } - } - ]; - fetchMock.mock('*', 503); - - return store.dispatch(processVnfVisualizationsOnFilterChange(filterValueMap)) - .then( () => { - const actions = store.getActions(); - expect(actions).toEqual(expectedActions); - fetchMock.restore(); - }); - }); - - it('Action: setNotificationText - no message', () => { - const middlewares = [thunk]; - const mockStore = configureStore(middlewares); - const store = mockStore({ vnfSearch: {} }); - store.dispatch(setNotificationText('', '')); - const actions = store.getActions(); - expect(actions).toEqual([{ - type: globalInlineMessageBarActionTypes.CLEAR_GLOBAL_MESSAGE - }]); - }); -}) diff --git a/test/vnfSearch/VnfSearchNfRoleVisualization.test.js b/test/vnfSearch/VnfSearchNfRoleVisualization.test.js deleted file mode 100644 index 2265e6e..0000000 --- a/test/vnfSearch/VnfSearchNfRoleVisualization.test.js +++ /dev/null @@ -1,154 +0,0 @@ -import React from 'react'; -import { shallow, mount } from 'enzyme'; -import {Provider} from 'react-redux' -import configureStore from 'redux-mock-store'; -import { BarChart } from 'recharts'; - -import ConnectedVnfSearchNfRoleVisualization, - { VnfSearchNfRoleVisualization } from 'app/vnfSearch/VnfSearchNfRoleVisualization.jsx'; -import { CHART_NF_ROLE } from 'app/vnfSearch/VnfSearchConstants.js'; -import Spinner from 'utils/SpinnerContainer.jsx'; - -describe('VnfSearchNfRoleVisualization - Shallow render of component', () => { - let wrapper; - const processedNfRoleCountChartDataProp = { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }; - - beforeEach( () => { - wrapper = shallow( - - ); - }) - - it('Render basic component', () => { - expect(wrapper.length).toEqual(1); - expect(wrapper.hasClass('visualizations')).toEqual(true); - }); - - it('Verify Spinner is present but not visible', () => { - expect(wrapper.find(Spinner)).toHaveLength(1); - expect(wrapper.find(Spinner).props().loading).toEqual(false); - }); - - it('Verify BarChart is displayed', () => { - expect(wrapper.find(BarChart)).toHaveLength(1); - expect(wrapper.find(BarChart).props().data).toEqual(processedNfRoleCountChartDataProp.values); - }); -}) - -describe('VnfSearchNfRoleVisualization - Shallow render of component with no chart data', () => { - let wrapper; - const processedNfRoleCountChartDataProp = { - values: null - }; - - beforeEach( () => { - wrapper = shallow( - - ); - }) - - it('Visualization graph hidden', () => { - expect(wrapper.length).toEqual(1); - expect(['visualizations', 'hidden'].every(className => wrapper.hasClass(className))).toEqual(true); - }); -}) - -describe('VnfSearchNfRoleVisualization - Shallow render of component with busy feedback', () => { - let wrapper; - const processedNfRoleCountChartDataProp = { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }; - - beforeEach( () => { - wrapper = shallow( - - ); - }) - - it('Render basic component', () => { - expect(wrapper.length).toEqual(1); - expect(wrapper.hasClass('visualizations')).toEqual(true); - }); - - it('Verify Spinner is present and visible', () => { - expect(wrapper.find(Spinner)).toHaveLength(1); - expect(wrapper.find(Spinner).props().loading).toEqual(true); - }); - - it('Verify BarChart is displayed', () => { - expect(wrapper.find(BarChart)).toHaveLength(1); - expect(wrapper.find(BarChart).props().data).toEqual(processedNfRoleCountChartDataProp.values); - }); -}) - -describe('VnfSearchNfRoleVisualization - Render React Component (wrapped in )', () => { - const initialState = { - vnfSearch: { - processedNfRoleCountChartData: { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }, - enableBusyFeedback: false - } - }; - const mockStore = configureStore(); - let store, wrapper; - - beforeEach( () => { - store = mockStore(initialState); - wrapper = mount(); - }) - - it('Render the connected component', () => { - expect(wrapper.find(ConnectedVnfSearchNfRoleVisualization).length).toEqual(1); - }); - - it('Validate props from store', () => { - expect(wrapper.find(VnfSearchNfRoleVisualization).props().enableBusyFeedback).toEqual(initialState.vnfSearch.enableBusyFeedback); - expect(wrapper.find(VnfSearchNfRoleVisualization).props().processedNfRoleCountChartData).toEqual(initialState.vnfSearch.processedNfRoleCountChartData); - }); -}) - -describe('VnfSearchNfRoleVisualization - Render React Component (wrapped in ) with default props', () => { - const initialState = { - vnfSearch: {} - }; - const mockStore = configureStore(); - let store, wrapper; - - beforeEach( () => { - store = mockStore(initialState); - wrapper = mount(); - }) - - it('Render the connected component', () => { - expect(wrapper.find(ConnectedVnfSearchNfRoleVisualization).length).toEqual(1); - }); - - it('Validate default props loaded', () => { - expect(wrapper.find(VnfSearchNfRoleVisualization).props().enableBusyFeedback).toEqual(false); - expect(wrapper.find(VnfSearchNfRoleVisualization).props().processedNfRoleCountChartData).toEqual(CHART_NF_ROLE.emptyData); - }); -}) diff --git a/test/vnfSearch/VnfSearchNfTypeVisualization.test.js b/test/vnfSearch/VnfSearchNfTypeVisualization.test.js deleted file mode 100644 index 485a822..0000000 --- a/test/vnfSearch/VnfSearchNfTypeVisualization.test.js +++ /dev/null @@ -1,154 +0,0 @@ -import React from 'react'; -import { shallow, mount } from 'enzyme'; -import {Provider} from 'react-redux' -import configureStore from 'redux-mock-store'; -import { BarChart } from 'recharts'; - -import ConnectedVnfSearchNfTypeVisualization, - { VnfSearchNfTypeVisualization } from 'app/vnfSearch/VnfSearchNfTypeVisualization.jsx'; -import { CHART_NF_TYPE } from 'app/vnfSearch/VnfSearchConstants.js'; -import Spinner from 'utils/SpinnerContainer'; - -describe('VnfSearchNfTypeVisualization - Shallow render of component', () => { - let wrapper; - const processedNfTypeCountChartDataProp = { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }; - - beforeEach( () => { - wrapper = shallow( - - ); - }) - - it('Render basic component', () => { - expect(wrapper.length).toEqual(1); - expect(wrapper.hasClass('visualizations')).toEqual(true); - }); - - it('Verify Spinner is present but not visible', () => { - expect(wrapper.find(Spinner)).toHaveLength(1); - expect(wrapper.find(Spinner).props().loading).toEqual(false); - }); - - it('Verify BarChart is displayed', () => { - expect(wrapper.find(BarChart)).toHaveLength(1); - expect(wrapper.find(BarChart).props().data).toEqual(processedNfTypeCountChartDataProp.values); - }); -}) - -describe('VnfSearchNfTypeVisualization - Shallow render of component with no chart data', () => { - let wrapper; - const processedNfTypeCountChartDataProp = { - values: null - }; - - beforeEach( () => { - wrapper = shallow( - - ); - }) - - it('Visualization graph hidden', () => { - expect(wrapper.length).toEqual(1); - expect(['visualizations', 'hidden'].every(className => wrapper.hasClass(className))).toEqual(true); - }); -}) - -describe('VnfSearchNfTypeVisualization - Shallow render of component with busy feedback', () => { - let wrapper; - const processedNfTypeCountChartDataProp = { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }; - - beforeEach( () => { - wrapper = shallow( - - ); - }) - - it('Render basic component', () => { - expect(wrapper.length).toEqual(1); - expect(wrapper.hasClass('visualizations')).toEqual(true); - }); - - it('Verify Spinner is present and visible', () => { - expect(wrapper.find(Spinner)).toHaveLength(1); - expect(wrapper.find(Spinner).props().loading).toEqual(true); - }); - - it('Verify BarChart is displayed', () => { - expect(wrapper.find(BarChart)).toHaveLength(1); - expect(wrapper.find(BarChart).props().data).toEqual(processedNfTypeCountChartDataProp.values); - }); -}) - -describe('VnfSearchNfTypeVisualization - Render React Component (wrapped in )', () => { - const initialState = { - vnfSearch: { - processedNfTypeCountChartData: { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }, - enableBusyFeedback: false - } - }; - const mockStore = configureStore(); - let store, wrapper; - - beforeEach( () => { - store = mockStore(initialState); - wrapper = mount(); - }) - - it('Render the connected component', () => { - expect(wrapper.find(ConnectedVnfSearchNfTypeVisualization).length).toEqual(1); - }); - - it('Validate props from store', () => { - expect(wrapper.find(VnfSearchNfTypeVisualization).props().enableBusyFeedback).toEqual(initialState.vnfSearch.enableBusyFeedback); - expect(wrapper.find(VnfSearchNfTypeVisualization).props().processedNfTypeCountChartData).toEqual(initialState.vnfSearch.processedNfTypeCountChartData); - }); -}) - -describe('VnfSearchNfTypeVisualization - Render React Component (wrapped in ) with default props', () => { - const initialState = { - vnfSearch: {} - }; - const mockStore = configureStore(); - let store, wrapper; - - beforeEach( () => { - store = mockStore(initialState); - wrapper = mount(); - }) - - it('Render the connected component', () => { - expect(wrapper.find(ConnectedVnfSearchNfTypeVisualization).length).toEqual(1); - }); - - it('Validate default props loaded', () => { - expect(wrapper.find(VnfSearchNfTypeVisualization).props().enableBusyFeedback).toEqual(false); - expect(wrapper.find(VnfSearchNfTypeVisualization).props().processedNfTypeCountChartData).toEqual(CHART_NF_TYPE.emptyData); - }); -}) diff --git a/test/vnfSearch/VnfSearchOrchestratedStatusVisualization.test.js b/test/vnfSearch/VnfSearchOrchestratedStatusVisualization.test.js deleted file mode 100644 index 2586079..0000000 --- a/test/vnfSearch/VnfSearchOrchestratedStatusVisualization.test.js +++ /dev/null @@ -1,154 +0,0 @@ -import React from 'react'; -import { shallow, mount } from 'enzyme'; -import {Provider} from 'react-redux' -import configureStore from 'redux-mock-store'; -import { BarChart } from 'recharts'; - -import ConnectedVnfSearchOrchStatusVisualizations, - { VnfSearchOrchStatusVisualizations } from 'app/vnfSearch/VnfSearchOrchestratedStatusVisualization.jsx'; -import { CHART_ORCH_STATUS } from 'app/vnfSearch/VnfSearchConstants.js'; -import Spinner from 'utils/SpinnerContainer'; - -describe('VnfSearchOrchStatusVisualizations - Shallow render of component', () => { - let wrapper; - const processedOrchStatusCountChartDataProp = { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }; - - beforeEach( () => { - wrapper = shallow( - - ); - }) - - it('Render basic component', () => { - expect(wrapper.length).toEqual(1); - expect(wrapper.hasClass('visualizations')).toEqual(true); - }); - - it('Verify Spinner is present but not visible', () => { - expect(wrapper.find(Spinner)).toHaveLength(1); - expect(wrapper.find(Spinner).props().loading).toEqual(false); - }); - - it('Verify BarChart is displayed', () => { - expect(wrapper.find(BarChart)).toHaveLength(1); - expect(wrapper.find(BarChart).props().data).toEqual(processedOrchStatusCountChartDataProp.values); - }); -}) - -describe('VnfSearchOrchStatusVisualizations - Shallow render of component with no chart data', () => { - let wrapper; - const processedOrchStatusCountChartDataProp = { - values: null - }; - - beforeEach( () => { - wrapper = shallow( - - ); - }) - - it('Visualization graph hidden', () => { - expect(wrapper.length).toEqual(1); - expect(['visualizations', 'hidden'].every(className => wrapper.hasClass(className))).toEqual(true); - }); -}) - -describe('VnfSearchOrchStatusVisualizations - Shallow render of component with busy feedback', () => { - let wrapper; - const processedOrchStatusCountChartDataProp = { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }; - - beforeEach( () => { - wrapper = shallow( - - ); - }) - - it('Render basic component', () => { - expect(wrapper.length).toEqual(1); - expect(wrapper.hasClass('visualizations')).toEqual(true); - }); - - it('Verify Spinner is present and visible', () => { - expect(wrapper.find(Spinner)).toHaveLength(1); - expect(wrapper.find(Spinner).props().loading).toEqual(true); - }); - - it('Verify BarChart is displayed', () => { - expect(wrapper.find(BarChart)).toHaveLength(1); - expect(wrapper.find(BarChart).props().data).toEqual(processedOrchStatusCountChartDataProp.values); - }); -}) - -describe('VnfSearchOrchStatusVisualizations - Render React Component (wrapped in )', () => { - const initialState = { - vnfSearch: { - processedOrchStatusCountChartData: { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }, - enableBusyFeedback: false - } - }; - const mockStore = configureStore(); - let store, wrapper; - - beforeEach( () => { - store = mockStore(initialState); - wrapper = mount(); - }) - - it('Render the connected component', () => { - expect(wrapper.find(ConnectedVnfSearchOrchStatusVisualizations).length).toEqual(1); - }); - - it('Validate props from store', () => { - expect(wrapper.find(VnfSearchOrchStatusVisualizations).props().enableBusyFeedback).toEqual(initialState.vnfSearch.enableBusyFeedback); - expect(wrapper.find(VnfSearchOrchStatusVisualizations).props().processedOrchStatusCountChartData).toEqual(initialState.vnfSearch.processedOrchStatusCountChartData); - }); -}) - -describe('VnfSearchOrchStatusVisualizations - Render React Component (wrapped in ) with default props', () => { - const initialState = { - vnfSearch: {} - }; - const mockStore = configureStore(); - let store, wrapper; - - beforeEach( () => { - store = mockStore(initialState); - wrapper = mount(); - }) - - it('Render the connected component', () => { - expect(wrapper.find(ConnectedVnfSearchOrchStatusVisualizations).length).toEqual(1); - }); - - it('Validate default props loaded', () => { - expect(wrapper.find(VnfSearchOrchStatusVisualizations).props().enableBusyFeedback).toEqual(false); - expect(wrapper.find(VnfSearchOrchStatusVisualizations).props().processedOrchStatusCountChartData).toEqual(CHART_ORCH_STATUS.emptyData); - }); -}) diff --git a/test/vnfSearch/VnfSearchProvStatusVisualization.test.js b/test/vnfSearch/VnfSearchProvStatusVisualization.test.js deleted file mode 100644 index f3e7279..0000000 --- a/test/vnfSearch/VnfSearchProvStatusVisualization.test.js +++ /dev/null @@ -1,154 +0,0 @@ -import React from 'react'; -import { shallow, mount } from 'enzyme'; -import {Provider} from 'react-redux' -import configureStore from 'redux-mock-store'; -import { BarChart } from 'recharts'; - -import ConnectedVnfSearchProvStatusVisualization, - { VnfSearchProvStatusVisualization } from 'app/vnfSearch/VnfSearchProvStatusVisualization.jsx'; -import { CHART_PROV_STATUS } from 'app/vnfSearch/VnfSearchConstants.js'; -import Spinner from 'utils/SpinnerContainer'; - -describe('VnfSearchProvStatusVisualization - Shallow render of component', () => { - let wrapper; - const processedProvStatusCountChartDataProp = { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }; - - beforeEach( () => { - wrapper = shallow( - - ); - }) - - it('Render basic component', () => { - expect(wrapper.length).toEqual(1); - expect(wrapper.hasClass('visualizations')).toEqual(true); - }); - - it('Verify Spinner is present but not visible', () => { - expect(wrapper.find(Spinner)).toHaveLength(1); - expect(wrapper.find(Spinner).props().loading).toEqual(false); - }); - - it('Verify BarChart is displayed', () => { - expect(wrapper.find(BarChart)).toHaveLength(1); - expect(wrapper.find(BarChart).props().data).toEqual(processedProvStatusCountChartDataProp.values); - }); -}) - -describe('VnfSearchProvStatusVisualization - Shallow render of component with no chart data', () => { - let wrapper; - const processedProvStatusCountChartDataProp = { - values: null - }; - - beforeEach( () => { - wrapper = shallow( - - ); - }) - - it('Visualization graph hidden', () => { - expect(wrapper.length).toEqual(1); - expect(['visualizations', 'hidden'].every(className => wrapper.hasClass(className))).toEqual(true); - }); -}) - -describe('VnfSearchProvStatusVisualization - Shallow render of component with busy feedback', () => { - let wrapper; - const processedProvStatusCountChartDataProp = { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }; - - beforeEach( () => { - wrapper = shallow( - - ); - }) - - it('Render basic component', () => { - expect(wrapper.length).toEqual(1); - expect(wrapper.hasClass('visualizations')).toEqual(true); - }); - - it('Verify Spinner is present and visible', () => { - expect(wrapper.find(Spinner)).toHaveLength(1); - expect(wrapper.find(Spinner).props().loading).toEqual(true); - }); - - it('Verify BarChart is displayed', () => { - expect(wrapper.find(BarChart)).toHaveLength(1); - expect(wrapper.find(BarChart).props().data).toEqual(processedProvStatusCountChartDataProp.values); - }); -}) - -describe('VnfSearchProvStatusVisualization - Render React Component (wrapped in )', () => { - const initialState = { - vnfSearch: { - processedProvStatusCountChartData: { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }, - enableBusyFeedback: false - } - }; - const mockStore = configureStore(); - let store, wrapper; - - beforeEach( () => { - store = mockStore(initialState); - wrapper = mount(); - }) - - it('Render the connected component', () => { - expect(wrapper.find(ConnectedVnfSearchProvStatusVisualization).length).toEqual(1); - }); - - it('Validate props from store', () => { - expect(wrapper.find(VnfSearchProvStatusVisualization).props().enableBusyFeedback).toEqual(initialState.vnfSearch.enableBusyFeedback); - expect(wrapper.find(VnfSearchProvStatusVisualization).props().processedProvStatusCountChartData).toEqual(initialState.vnfSearch.processedProvStatusCountChartData); - }); -}) - -describe('VnfSearchProvStatusVisualization - Render React Component (wrapped in ) with default props', () => { - const initialState = { - vnfSearch: {} - }; - const mockStore = configureStore(); - let store, wrapper; - - beforeEach( () => { - store = mockStore(initialState); - wrapper = mount(); - }) - - it('Render the connected component', () => { - expect(wrapper.find(ConnectedVnfSearchProvStatusVisualization).length).toEqual(1); - }); - - it('Validate default props loaded', () => { - expect(wrapper.find(VnfSearchProvStatusVisualization).props().enableBusyFeedback).toEqual(false); - expect(wrapper.find(VnfSearchProvStatusVisualization).props().processedProvStatusCountChartData).toEqual(CHART_PROV_STATUS.emptyData); - }); -}) diff --git a/test/vnfSearch/VnfSearchReducer.test.js b/test/vnfSearch/VnfSearchReducer.test.js deleted file mode 100644 index 381a696..0000000 --- a/test/vnfSearch/VnfSearchReducer.test.js +++ /dev/null @@ -1,438 +0,0 @@ -import VnfSearchReducer from 'app/vnfSearch/VnfSearchReducer.js'; -import { - vnfActionTypes, - CHART_ORCH_STATUS, - CHART_PROV_STATUS, - CHART_NF_ROLE, - CHART_NF_TYPE, - TOTAL_VNF_COUNT -} from 'app/vnfSearch/VnfSearchConstants.js'; -import {ERROR_RETRIEVING_DATA} from 'app/networking/NetworkConstants.js'; -import { - filterBarActionTypes, - MESSAGE_LEVEL_DANGER -} from 'utils/GlobalConstants'; -import { - globalAutoCompleteSearchBarActionTypes -} from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants.js'; - -describe('VnfSearchReducer - Reducer Action Type Tests', () => { - it('Action Type: VNF_NETWORK_ERROR', () => { - const action = { - type: vnfActionTypes.VNF_NETWORK_ERROR - }; - let state = { - processedProvStatusCountChartData: { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }, - processedOrchStatusCountChartData: { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }, - processedNfTypeCountChartData: { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }, - processedNfRoleCountChartData: { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }, - count: 20, - feedbackMsgText: '', - feedbackMsgSeverity: '' - }; - state = VnfSearchReducer(state, action); - expect(state).toEqual({ - processedProvStatusCountChartData: CHART_PROV_STATUS.emptyData, - processedOrchStatusCountChartData: CHART_ORCH_STATUS.emptyData, - processedNfTypeCountChartData: CHART_NF_TYPE.emptyData, - processedNfRoleCountChartData: CHART_NF_ROLE.emptyData, - count: TOTAL_VNF_COUNT.emptyValue, - feedbackMsgText: ERROR_RETRIEVING_DATA, - feedbackMsgSeverity: MESSAGE_LEVEL_DANGER - }); - }); - - it('Action Type: SEARCH_WARNING_EVENT', () => { - const action = { - type: globalAutoCompleteSearchBarActionTypes.SEARCH_WARNING_EVENT - }; - let state = { - processedProvStatusCountChartData: { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }, - processedOrchStatusCountChartData: { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }, - processedNfTypeCountChartData: { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }, - processedNfRoleCountChartData: { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }, - count: 20, - }; - state = VnfSearchReducer(state, action); - expect(state).toEqual({ - processedProvStatusCountChartData: CHART_PROV_STATUS.emptyData, - processedOrchStatusCountChartData: CHART_ORCH_STATUS.emptyData, - processedNfTypeCountChartData: CHART_NF_TYPE.emptyData, - processedNfRoleCountChartData: CHART_NF_ROLE.emptyData, - count: TOTAL_VNF_COUNT.emptyValue, - }); - }); - - it('Action Type: NEW_SELECTIONS', () => { - const action = { - type: filterBarActionTypes.NEW_SELECTIONS, - data: { - selectedValuesMap: [ - { filter1: ['someValue'] } - ], - unifiedValues: [ - { filter1: ['someValue', 'someOtherValue']} - ] - } - }; - let state = { - vnfFilterValues: {}, - unifiedFilterValues: {} - }; - state = VnfSearchReducer(state, action); - expect(state).toEqual({ - vnfFilterValues: action.data.selectedValuesMap, - unifiedFilterValues: action.data.unifiedValues - }); - }); - - it('Action Type: SET_UNIFIED_VALUES', () => { - const action = { - type: filterBarActionTypes.SET_UNIFIED_VALUES, - data: { - unifiedValues: [ - { filter1: ['someValue', 'someOtherValue']} - ] - } - }; - let state = { - unifiedFilterValues: {} - }; - state = VnfSearchReducer(state, action); - expect(state).toEqual({ - unifiedFilterValues: action.data - }); - }); - - it('Action Type: VNF_SEARCH_RESULTS_RECEIVED', () => { - const action = { - type: vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED, - data: { - provStatusData: { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }, - orchStatusData: { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }, - nfTypeData: { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }, - nfRoleData: { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }, - count: 25, - } - }; - let state = { - processedProvStatusCountChartData: {}, - processedOrchStatusCountChartData: {}, - processedNfTypeCountChartData: {}, - processedNfRoleCountChartData: {}, - count: 0, - feedbackMsgText: 'some error msg', - feedbackMsgSeverity: 'someSeverityLevel' - }; - state = VnfSearchReducer(state, action); - expect(state).toEqual({ - processedProvStatusCountChartData: action.data.provStatusData, - processedOrchStatusCountChartData: action.data.orchStatusData, - processedNfTypeCountChartData: action.data.nfTypeData, - processedNfRoleCountChartData: action.data.nfRoleData, - count: action.data.count, - feedbackMsgText: '', - feedbackMsgSeverity: '' - }); - }); - - it('Action Type: VNF_FILTER_PANEL_TOGGLED', () => { - const action = { - type: vnfActionTypes.VNF_FILTER_PANEL_TOGGLED, - data: { - vnfVisualizationPanelClass: 'hide', - } - }; - let state = { - vnfVisualizationPanelClass: 'show' - }; - state = VnfSearchReducer(state, action); - expect(state).toEqual({ - vnfVisualizationPanelClass: 'hide' - }); - }); - - it('Action Type: VNF_SEARCH_FILTERS_RECEIVED', () => { - const action = { - type: vnfActionTypes.VNF_SEARCH_FILTERS_RECEIVED, - data: [ - { filter1: 'value 1' }, - { filter2: 'value 2' } - ] - }; - let state = { - vnfFilters: [] - }; - state = VnfSearchReducer(state, action); - expect(state).toEqual({ - vnfFilters: action.data - }); - }); - - it('Action Type: SET_NON_CONVERTED_VALUES', () => { - const action = { - type: filterBarActionTypes.SET_NON_CONVERTED_VALUES, - data: [ - { value1: 'abc' }, - { value2: 'xyz' } - ] - }; - let state = { - nonConvertedFilters: [] - }; - state = VnfSearchReducer(state, action); - expect(state).toEqual({ - nonConvertedFilters: action.data - }); - }); - - it('Action Type: SET_CONVERTED_VALUES', () => { - const action = { - type: filterBarActionTypes.SET_CONVERTED_VALUES, - data: { - convertedValues: { - value1: 'abc', - value2: 'xyz' - }, - nonConvertedValues: { - value1: 123, - value2: 456 - } - } - }; - let state = { - nonConvertedFilters: { - filter1: 'one', - filter2: 'two' - }, - unifiedFilterValues: {}, - vnfFilterValues: {} - }; - state = VnfSearchReducer(state, action); - expect(state).toEqual({ - nonConvertedFilters: {}, - unifiedFilterValues: action.data.convertedValues, - vnfFilterValues: action.data.nonConvertedValues - }); - }); - - it('Action Type: VNF_ACTIVATE_BUSY_FEEDBACK', () => { - const action = { - type: vnfActionTypes.VNF_ACTIVATE_BUSY_FEEDBACK - }; - let state = { - enableBusyFeedback: false - }; - state = VnfSearchReducer(state, action); - expect(state).toEqual({ - enableBusyFeedback: true - }); - }); - - it('Action Type: VNF_DISABLE_BUSY_FEEDBACK', () => { - const action = { - type: vnfActionTypes.VNF_DISABLE_BUSY_FEEDBACK - }; - let state = { - enableBusyFeedback: true - }; - state = VnfSearchReducer(state, action); - expect(state).toEqual({ - enableBusyFeedback: false - }); - }); - - it('Action Type: CLEAR_FILTERS', () => { - const action = { - type: filterBarActionTypes.CLEAR_FILTERS - }; - let state = { - vnfFilters: { - filter1: 'filterName1' - }, - vnfFilterValues: { - filter1: 'value 1' - }, - nonConvertedFilters: { - nonConvertedFilter1: 'some fitler props' - }, - unifiedFilterValues: { - unifiedFilter1: 'some unified props' - } - }; - state = VnfSearchReducer(state, action); - expect(state).toEqual({ - vnfFilters: {}, - vnfFilterValues: {}, - nonConvertedFilters: {}, - unifiedFilterValues: {} - }); - }); - - it('Invalid Action Type', () => { - const action = { - type: 'Nonexistent Action Type', - }; - let state = { - vnfFilters: { - filter1: 'filterName1' - }, - vnfFilterValues: { - filter1: 'value 1' - }, - nonConvertedFilters: { - nonConvertedFilter1: 'some fitler props' - }, - unifiedFilterValues: { - unifiedFilter1: 'some unified props' - }, - enableBusyFeedback: true, - provStatusData: { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }, - orchStatusData: { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }, - nfTypeData: { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }, - nfRoleData: { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }, - count: 25 - }; - state = VnfSearchReducer(state, action); - expect(state).toEqual({ - vnfFilters: { - filter1: 'filterName1' - }, - vnfFilterValues: { - filter1: 'value 1' - }, - nonConvertedFilters: { - nonConvertedFilter1: 'some fitler props' - }, - unifiedFilterValues: { - unifiedFilter1: 'some unified props' - }, - enableBusyFeedback: true, - provStatusData: { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }, - orchStatusData: { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }, - nfTypeData: { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }, - nfRoleData: { - values: [ - {x: 'col 1', y: 3}, - {x: 'col 2', y: 7}, - {x: 'col 3', y: 2} - ] - }, - count: 25 - }); - }); -}) diff --git a/test/vnfSearch/VnfSearchTotalCountVisualization.test.js b/test/vnfSearch/VnfSearchTotalCountVisualization.test.js deleted file mode 100644 index a397ff2..0000000 --- a/test/vnfSearch/VnfSearchTotalCountVisualization.test.js +++ /dev/null @@ -1,131 +0,0 @@ -import React from 'react'; -import { shallow, mount } from 'enzyme'; -import {Provider} from 'react-redux' -import configureStore from 'redux-mock-store'; - -import ConnectedVnfSearchTotalCountVisualization, - { VnfSearchTotalCountVisualization } from 'app/vnfSearch/VnfSearchTotalCountVisualization.jsx'; -import { TOTAL_VNF_COUNT } from 'app/vnfSearch/VnfSearchConstants.js'; -import Spinner from 'utils/SpinnerContainer'; - -describe('VnfSearchTotalCountVisualization - Shallow render of component', () => { - let wrapper; - const countProp = 25; - - beforeEach( () => { - wrapper = shallow( - - ); - }) - - it('Render basic component', () => { - expect(wrapper.length).toEqual(1); - expect(wrapper.hasClass('visualizations')).toEqual(true); - }); - - it('Verify Spinner is present but not visible', () => { - expect(wrapper.find(Spinner)).toHaveLength(1); - expect(wrapper.find(Spinner).props().loading).toEqual(false); - }); - - it('Verify total count is displayed', () => { - expect(wrapper.contains({countProp})).toBe(true); - }); -}) - -describe('VnfSearchTotalCountVisualization - Shallow render of component with no chart data', () => { - let wrapper; - const countProp = null; - - beforeEach( () => { - wrapper = shallow( - - ); - }) - - it('Visualization graph hidden', () => { - expect(wrapper.length).toEqual(1); - expect(['visualizations', 'hidden'].every(className => wrapper.hasClass(className))).toEqual(true); - }); -}) - -describe('VnfSearchTotalCountVisualization - Shallow render of component with busy feedback', () => { - let wrapper; - const countProp = 25; - - beforeEach( () => { - wrapper = shallow( - - ); - }) - - it('Render basic component', () => { - expect(wrapper.length).toEqual(1); - expect(wrapper.hasClass('visualizations')).toEqual(true); - }); - - it('Verify Spinner is present and visible', () => { - expect(wrapper.find(Spinner)).toHaveLength(1); - expect(wrapper.find(Spinner).props().loading).toEqual(true); - }); - - it('Verify total count is displayed', () => { - expect(wrapper.contains({countProp})).toBe(true); - }); -}) - -describe('VnfSearchTotalCountVisualization - Render React Component (wrapped in )', () => { - const initialState = { - vnfSearch: { - count: 25, - enableBusyFeedback: false - } - }; - const mockStore = configureStore(); - let store, wrapper; - - beforeEach( () => { - store = mockStore(initialState); - wrapper = mount(); - }) - - it('Render the connected component', () => { - expect(wrapper.find(ConnectedVnfSearchTotalCountVisualization).length).toEqual(1); - }); - - it('Validate props from store', () => { - expect(wrapper.find(VnfSearchTotalCountVisualization).props().enableBusyFeedback).toEqual(initialState.vnfSearch.enableBusyFeedback); - expect(wrapper.find(VnfSearchTotalCountVisualization).props().count).toEqual(initialState.vnfSearch.count); - }); -}) - -describe('VnfSearchTotalCountVisualization - Render React Component (wrapped in ) with default props', () => { - const initialState = { - vnfSearch: {} - }; - const mockStore = configureStore(); - let store, wrapper; - - beforeEach( () => { - store = mockStore(initialState); - wrapper = mount(); - }) - - it('Render the connected component', () => { - expect(wrapper.find(ConnectedVnfSearchTotalCountVisualization).length).toEqual(1); - }); - - it('Validate default props loaded', () => { - expect(wrapper.find(VnfSearchTotalCountVisualization).props().enableBusyFeedback).toEqual(false); - expect(wrapper.find(VnfSearchTotalCountVisualization).props().count).toEqual(TOTAL_VNF_COUNT.emptyValue); - }); -}) -- cgit 1.2.3-korg