summaryrefslogtreecommitdiffstats
path: root/src/app/tierSupport/selectedNodeDetails
diff options
context:
space:
mode:
authorSteve Thomas <steventh@amdocs.com>2018-03-29 14:41:43 -0400
committerSteven Thomas <steve.thomas@amdocs.com>2018-03-29 14:57:35 -0400
commit0b2b11bad1457e7f388ab2a99af6ebf231e862e3 (patch)
tree8ef541c5b172893ca9b952cf251a7a78668ab6f1 /src/app/tierSupport/selectedNodeDetails
parent47b85e9b95e0a0a3570f0cea4d3ee4645c911a8b (diff)
increasing test coverage to 10%
Issue-ID: AAI-980 Change-Id: Idb816df11fa14b5668349f24bac1aafd7235e00a Signed-off-by: Steven Thomas <steve.thomas@amdocs.com>
Diffstat (limited to 'src/app/tierSupport/selectedNodeDetails')
-rw-r--r--src/app/tierSupport/selectedNodeDetails/SelectedNodeDetails.jsx2
-rw-r--r--src/app/tierSupport/selectedNodeDetails/SelectedNodeDetails.test.js141
-rw-r--r--src/app/tierSupport/selectedNodeDetails/SelectedNodeDetailsReducer.test.js248
3 files changed, 390 insertions, 1 deletions
diff --git a/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetails.jsx b/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetails.jsx
index 88536e6..5750fd9 100644
--- a/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetails.jsx
+++ b/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetails.jsx
@@ -39,7 +39,7 @@ let mapStateToProps = ({tierSupport: {selectedNodeDetails}}) => {
};
};
-class SelectedNodeDetails extends Component {
+export class SelectedNodeDetails extends Component {
static propTypes = {
nodeData: React.PropTypes.object,
nodeType: React.PropTypes.string,
diff --git a/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetails.test.js b/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetails.test.js
new file mode 100644
index 0000000..60f5530
--- /dev/null
+++ b/src/app/tierSupport/selectedNodeDetails/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 './SelectedNodeDetails.jsx';
+import { SELECTED_NODE_TABLE_COLUMN_NAMES } from './SelectedNodeDetailsConstants.js';
+import LaunchInContext from '../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/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetailsReducer.test.js b/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetailsReducer.test.js
new file mode 100644
index 0000000..2544a80
--- /dev/null
+++ b/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetailsReducer.test.js
@@ -0,0 +1,248 @@
+import SelectedNodeDetailsReducer from './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'
+ }
+ });
+ });
+})