diff options
author | James Forsyth <jf2512@att.com> | 2019-04-09 20:41:31 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-04-09 20:41:31 +0000 |
commit | cae868635ebe867b85223b056a5243c128192cbe (patch) | |
tree | 13db7f35d15a5463dfe3512e849ab4275a2ba346 /test/app/tierSupport | |
parent | 5b062c1f5005e14b6f18563ee875a06f5c1bc299 (diff) | |
parent | b0f2f345cc2d1cc3812ad8a06fc1898daf5842d0 (diff) |
Merge "Remove unused code"
Diffstat (limited to 'test/app/tierSupport')
-rw-r--r-- | test/app/tierSupport/SelectedNodeDetails.test.js | 141 | ||||
-rw-r--r-- | test/app/tierSupport/SelectedNodeDetailsReducer.test.js | 248 | ||||
-rw-r--r-- | test/app/tierSupport/TierSupportActions.test.js | 177 | ||||
-rw-r--r-- | test/app/tierSupport/TierSupportReducer.test.js | 206 |
4 files changed, 772 insertions, 0 deletions
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( + <SelectedNodeDetails + nodeType={nodeTypeProp} + nodeData={nodeDataProp} + uid={uidProp} + />); + }) + + it('Render basic component', () => { + expect(wrapper.length).toEqual(1); + }); + + it('Verify node type is displayed as a header', () => { + expect(wrapper.contains(<h2>{nodeTypeProp}</h2>)).toBe(true); + expect(wrapper.find('h2')).toHaveLength(1); + }); + + it('Verify uid is displayed', () => { + expect(wrapper.contains(<span>{uidProp} <LaunchInContext/></span>)).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( + <th className={cellClassName} key={index}>{SELECTED_NODE_TABLE_COLUMN_NAMES[index-1]}</th> + )).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( + <td className='left-column-cell'>{prop}</td> + )).toBe(true); + expect(wrapper.contains( + <td className='right-column-cell'>{nodeDataProp[prop]}</td> + )).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( + <SelectedNodeDetails + nodeType={nodeTypeProp} + nodeData={nodeDataProp} + uid={uidProp} + />); + }) + + 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 <Provider>)', () => { + 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(<Provider store={store}><ConnectedSelectedNodeDetails /></Provider>); + }) + + 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' + } + }); + }); +}) |