summaryrefslogtreecommitdiffstats
path: root/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetailsReducer.test.js
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/SelectedNodeDetailsReducer.test.js
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/SelectedNodeDetailsReducer.test.js')
-rw-r--r--src/app/tierSupport/selectedNodeDetails/SelectedNodeDetailsReducer.test.js248
1 files changed, 248 insertions, 0 deletions
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'
+ }
+ });
+ });
+})