From b0f2f345cc2d1cc3812ad8a06fc1898daf5842d0 Mon Sep 17 00:00:00 2001 From: Adam Wudzinski Date: Tue, 26 Mar 2019 16:47:06 +0100 Subject: Remove unused code Remove unsed code from generic-components and change tests directory structure to reflect src structure Change-Id: Iada2efb0f7cfb05557eb7cd709b8a0ed75976b03 Issue-ID: AAI-1618 Signed-off-by: awudzins --- .../GlobalAutoCompleteSearchBar.test.js | 35 ----- .../GlobalAutoCompleteSearchBarReducer.test.js | 154 --------------------- 2 files changed, 189 deletions(-) delete mode 100644 test/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBar.test.js delete mode 100644 test/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.test.js (limited to 'test/globalAutoCompleteSearchBar') diff --git a/test/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBar.test.js b/test/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBar.test.js deleted file mode 100644 index 25676b7..0000000 --- a/test/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBar.test.js +++ /dev/null @@ -1,35 +0,0 @@ -import React from 'react'; -import { mount } from 'enzyme'; -import {Provider} from 'react-redux' -import configureStore from 'redux-mock-store'; - -import GlobalAutoCompleteSearchBar from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBar.jsx' -import AutoCompleteSearchBar from 'generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.jsx'; -import { - globalAutoCompleteSearchBarActionTypes -} from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants.js'; - -describe('GlobalAutoCompleteSearchBarTests', () => { - const initValue = 'some random search text'; - const initialState = { - globalAutoCompleteSearchBarReducer: { - value: initValue - } - }; - const mockStore = configureStore(); - let store, wrapper; - - beforeEach( () => { - store = mockStore(initialState); - wrapper = mount(); - }) - - it('render search bar - visible', () => { - expect(wrapper).toHaveLength(1); // ensure the message bar is mounted - expect(wrapper.find(AutoCompleteSearchBar)).toHaveLength(1); // ensure the InlineMessage is mounted - }); - - it('props assigned properly', () => { - expect(wrapper.find(AutoCompleteSearchBar).props().value).toEqual(initValue); // check that the props match - }) -}) diff --git a/test/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.test.js b/test/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.test.js deleted file mode 100644 index 1078df6..0000000 --- a/test/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.test.js +++ /dev/null @@ -1,154 +0,0 @@ -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 - }); - }); -}) -- cgit 1.2.3-korg