1 import TierSupportReducer from 'app/tierSupport/TierSupportReducer.js';
2 import ForceDirectedGraph from 'generic-components/graph/ForceDirectedGraph.jsx';
4 tierSupportActionTypes,
5 TSUI_GRAPH_MENU_NODE_DETAILS
6 } from 'app/tierSupport/TierSupportConstants.js';
10 } from 'utils/GlobalConstants.js';
12 globalAutoCompleteSearchBarActionTypes
13 } from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants.js';
15 describe('TierSupportReducerTests', () => {
16 it('Action Type: TS_NODE_SEARCH_RESULTS', () => {
17 ForceDirectedGraph.graphCounter = 0; // ensuring counter is at zero after previous tests
19 type: tierSupportActionTypes.TS_NODE_SEARCH_RESULTS,
26 itemProperties: 'someProperty'
29 links: ['link', 'information'],
30 graphMeta: { graph: 'meta' }
33 let graphData = ForceDirectedGraph.generateNewProps(action.data.nodes, action.data.links,
34 action.data.graphMeta);
35 ForceDirectedGraph.graphCounter = 0; // ensuring counter is at zero after previous statement
37 state = TierSupportReducer(state, action);
38 expect(state.tierSupportReducer).toEqual({
39 forceDirectedGraphRawData: graphData,
41 feedbackMsgSeverity: ''
45 it('Action Type: TS_GRAPH_NODE_MENU_SELECTED', () => {
47 type: tierSupportActionTypes.TS_GRAPH_NODE_MENU_SELECTED,
50 attr2: 'someOterValue'
54 state = TierSupportReducer(state, action);
55 expect(state.tierSupportReducer).toEqual({
56 graphNodeSelectedMenu: action.data
60 it('Action Type: TS_NODE_SEARCH_NO_RESULTS', () => {
61 ForceDirectedGraph.graphCounter = 0; // ensuring counter is at zero after previous tests
62 let emptyNodesAndLinksNoResults = {
69 type: tierSupportActionTypes.TS_NODE_SEARCH_NO_RESULTS,
71 errorMsg: 'some error message'
75 state = TierSupportReducer(state, action);
76 expect(state.tierSupportReducer).toEqual({
77 forceDirectedGraphRawData: emptyNodesAndLinksNoResults,
78 graphNodeSelectedMenu: TSUI_GRAPH_MENU_NODE_DETAILS,
79 feedbackMsgText: action.data.errorMsg,
80 feedbackMsgSeverity: MESSAGE_LEVEL_WARNING
84 it('Action Type: TIER_SUPPORT_NETWORK_ERROR', () => {
85 ForceDirectedGraph.graphCounter = 0; // ensuring counter is at zero after previous tests
86 let emptyNodesAndLinksNoResults = {
93 type: tierSupportActionTypes.TIER_SUPPORT_NETWORK_ERROR,
95 errorMsg: 'some error message'
99 state = TierSupportReducer(state, action);
100 expect(state.tierSupportReducer).toEqual({
101 forceDirectedGraphRawData: emptyNodesAndLinksNoResults,
102 graphNodeSelectedMenu: TSUI_GRAPH_MENU_NODE_DETAILS,
103 feedbackMsgText: action.data.errorMsg,
104 feedbackMsgSeverity: MESSAGE_LEVEL_DANGER
108 it('Action Type: TIER_SUPPORT_CLEAR_DATA', () => {
109 ForceDirectedGraph.graphCounter = 0; // ensuring counter is at zero after previous tests
110 let emptyNodesAndLinksNoResults = {
117 type: tierSupportActionTypes.TIER_SUPPORT_CLEAR_DATA
120 state = TierSupportReducer(state, action);
121 expect(state.tierSupportReducer).toEqual({
122 forceDirectedGraphRawData: emptyNodesAndLinksNoResults,
123 graphNodeSelectedMenu: TSUI_GRAPH_MENU_NODE_DETAILS,
125 feedbackMsgSeverity: ''
129 it('Action Type: TS_GRAPH_NODE_SELECTED', () => {
131 type: tierSupportActionTypes.TS_GRAPH_NODE_SELECTED,
132 data: 'some action data'
135 state = TierSupportReducer(state, action);
136 expect(state.tierSupportReducer).toEqual({
137 nodeData: action.data
141 it('Action Type: TIER_SUPPORT_ACTIVATE_BUSY_FEEDBACK', () => {
143 type: tierSupportActionTypes.TIER_SUPPORT_ACTIVATE_BUSY_FEEDBACK,
146 state = TierSupportReducer(state, action);
147 expect(state.tierSupportReducer).toEqual({
148 enableBusyFeedback: true
152 it('Action Type: TIER_SUPPORT_DISABLE_BUSY_FEEDBACK', () => {
154 type: tierSupportActionTypes.TIER_SUPPORT_DISABLE_BUSY_FEEDBACK,
157 state = TierSupportReducer(state, action);
158 expect(state.tierSupportReducer).toEqual({
159 enableBusyFeedback: false
163 it('Action Type: SEARCH_WARNING_EVENT', () => {
164 ForceDirectedGraph.graphCounter = 0; // ensuring counter is at zero after previous tests
165 let emptyNodesAndLinksNoResults = {
172 type: globalAutoCompleteSearchBarActionTypes.SEARCH_WARNING_EVENT,
174 errorMsg: 'some warning msg'
178 state = TierSupportReducer(state, action);
179 expect(state.tierSupportReducer).toEqual({
180 forceDirectedGraphRawData: emptyNodesAndLinksNoResults,
181 graphNodeSelectedMenu: TSUI_GRAPH_MENU_NODE_DETAILS
185 it('Action Type: TS_OVERLAY_NETWORK_CALLBACK_RESPONSE_RECEIVED', () => {
187 type: tierSupportActionTypes.TS_OVERLAY_NETWORK_CALLBACK_RESPONSE_RECEIVED,
194 overlayData: 'someValue2'
198 state = TierSupportReducer(state, action);
199 expect(state.tierSupportReducer).toEqual({