summaryrefslogtreecommitdiffstats
path: root/test/tierSupport/SelectedNodeDetailsReducer.test.js
diff options
context:
space:
mode:
authorArul.Nambi <arul.nambi@amdocs.com>2018-07-11 14:19:41 -0400
committerArul.Nambi <arul.nambi@amdocs.com>2018-07-16 10:04:10 -0400
commit75597ac2b51ba62bee33f72a7b55a549cf43a16f (patch)
tree9e9b6826a51abbdd011e5449c4812e8cca6d58a1 /test/tierSupport/SelectedNodeDetailsReducer.test.js
parent4cbfb73eebc578c62ff38c82f969782e229ce969 (diff)
Refactoring test scripts
Moving the test scripts under one folder and restucting them so that the clutter can be avoided in the src folder. Issue-ID: AAI-1371 Change-Id: I41b34acbe79a7a3409f2990f11492614f7ef9c5a Signed-off-by: Arul.Nambi <arul.nambi@amdocs.com>
Diffstat (limited to 'test/tierSupport/SelectedNodeDetailsReducer.test.js')
-rw-r--r--test/tierSupport/SelectedNodeDetailsReducer.test.js248
1 files changed, 248 insertions, 0 deletions
diff --git a/test/tierSupport/SelectedNodeDetailsReducer.test.js b/test/tierSupport/SelectedNodeDetailsReducer.test.js
new file mode 100644
index 0000000..238d21c
--- /dev/null
+++ b/test/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'
+ }
+ });
+ });
+})