summaryrefslogtreecommitdiffstats
path: root/test/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.test.js
diff options
context:
space:
mode:
authorJames Forsyth <jf2512@att.com>2019-04-09 20:41:31 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-09 20:41:31 +0000
commitcae868635ebe867b85223b056a5243c128192cbe (patch)
tree13db7f35d15a5463dfe3512e849ab4275a2ba346 /test/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.test.js
parent5b062c1f5005e14b6f18563ee875a06f5c1bc299 (diff)
parentb0f2f345cc2d1cc3812ad8a06fc1898daf5842d0 (diff)
Merge "Remove unused code"
Diffstat (limited to 'test/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.test.js')
-rw-r--r--test/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.test.js154
1 files changed, 154 insertions, 0 deletions
diff --git a/test/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.test.js b/test/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.test.js
new file mode 100644
index 0000000..1078df6
--- /dev/null
+++ b/test/app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.test.js
@@ -0,0 +1,154 @@
+import i18n from 'utils/i18n/i18n';
+import GlobalAutoCompleteSearchBarReducer from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.js';
+import {
+ globalAutoCompleteSearchBarActionTypes,
+ NO_MATCHES_FOUND
+} from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants.js';
+import {
+ MESSAGE_LEVEL_WARNING,
+ MESSAGE_LEVEL_DANGER
+} from 'utils/GlobalConstants.js';
+
+describe('GlobalAutoCompleteSearchBarReducerTests', () => {
+ it('Action Type: SUGGESTION_FOUND', () => {
+ const suggestions = [
+ {
+ entityType: 'some entity type',
+ value: 'selected value'
+ },
+ {
+ entityType: 'some entity type',
+ value: 'other selected value'
+ }
+ ];
+ const errMsg = 'some error message';
+ const action = {
+ type: globalAutoCompleteSearchBarActionTypes.SUGGESTION_FOUND,
+ data: {
+ suggestions: suggestions,
+ errorMsg: errMsg
+ }
+ };
+ let state = {};
+ state = GlobalAutoCompleteSearchBarReducer(state, action);
+ expect(state).toEqual({
+ suggestions: suggestions,
+ cachedSuggestions: suggestions,
+ feedbackMsgText: errMsg,
+ feedbackMsgSeverity: MESSAGE_LEVEL_DANGER
+ });
+ });
+
+ it('Action Type: SUGGESTION_NOT_FOUND', () => {
+ const action = {
+ type: globalAutoCompleteSearchBarActionTypes.SUGGESTION_NOT_FOUND,
+ };
+ let state = {};
+ state = GlobalAutoCompleteSearchBarReducer(state, action);
+ expect(state).toEqual({
+ suggestions: [{ text: i18n(NO_MATCHES_FOUND)}],
+ cachedSuggestions: [{ entityType: i18n(NO_MATCHES_FOUND)}],
+ feedbackMsgText: '',
+ feedbackMsgSeverity: ''
+ });
+ });
+
+ it('Action Type: CLEAR_SUGGESTIONS_TEXT_FIELD', () => {
+ const action = {
+ type: globalAutoCompleteSearchBarActionTypes.CLEAR_SUGGESTIONS_TEXT_FIELD,
+ };
+ let state = {};
+ state = GlobalAutoCompleteSearchBarReducer(state, action);
+ expect(state).toEqual({
+ suggestions: [],
+ cachedSuggestions: [],
+ value: '',
+ feedbackMsgText: '',
+ feedbackMsgSeverity: '',
+ clearSearchText: false
+ });
+ });
+
+ it('Action Type: CLEAR_SUGGESTIONS', () => {
+ const action = {
+ type: globalAutoCompleteSearchBarActionTypes.CLEAR_SUGGESTIONS,
+ };
+ let state = {};
+ state = GlobalAutoCompleteSearchBarReducer(state, action);
+ expect(state).toEqual({
+ suggestions: []
+ });
+ });
+
+ it('Action Type: SUGGESTION_CHANGED', () => {
+ const suggestionText = 'some suggestion text';
+ const action = {
+ type: globalAutoCompleteSearchBarActionTypes.SUGGESTION_CHANGED,
+ data: suggestionText
+ };
+ let state = {};
+ state = GlobalAutoCompleteSearchBarReducer(state, action);
+ expect(state).toEqual({
+ value: suggestionText,
+ feedbackMsgText: '',
+ feedbackMsgSeverity: ''
+ });
+ });
+
+ it('Action Type: SUGGESTION_CLICKED', () => {
+ const suggestion = {
+ entityType: 'some entity type',
+ value: 'selected value'
+ };
+ const action = {
+ type: globalAutoCompleteSearchBarActionTypes.SUGGESTION_CLICKED,
+ data: {
+ selectedSuggestion: suggestion
+ }
+ };
+ let state = {};
+ state = GlobalAutoCompleteSearchBarReducer(state, action);
+ expect(state).toEqual({
+ selectedSuggestion: suggestion,
+ performPrepareVisualization: true,
+ feedbackMsgText: '',
+ feedbackMsgSeverity: ''
+ });
+ });
+
+ it('Action Type: NETWORK_ERROR', () => {
+ const errMsg = 'some error message';
+ const action = {
+ type: globalAutoCompleteSearchBarActionTypes.NETWORK_ERROR,
+ data: {
+ errorMsg: errMsg
+ }
+ };
+ let state = {};
+ state = GlobalAutoCompleteSearchBarReducer(state, action);
+ expect(state).toEqual({
+ suggestions: [],
+ cachedSuggestions: [],
+ feedbackMsgText: errMsg,
+ feedbackMsgSeverity: MESSAGE_LEVEL_DANGER
+ });
+ });
+
+ it('Action Type: SEARCH_WARNING_EVENT', () => {
+ const errMsg = 'some error message';
+ const action = {
+ type: globalAutoCompleteSearchBarActionTypes.SEARCH_WARNING_EVENT,
+ data: {
+ errorMsg: errMsg
+ }
+ };
+ let state = {};
+ state = GlobalAutoCompleteSearchBarReducer(state, action);
+ expect(state).toEqual({
+ suggestions: [],
+ cachedSuggestions: [],
+ feedbackMsgText: errMsg,
+ feedbackMsgSeverity: MESSAGE_LEVEL_WARNING
+ });
+ });
+})