diff options
author | Adam Wudzinski <adam.wudzinski@nokia.com> | 2019-03-26 16:47:06 +0100 |
---|---|---|
committer | awudzins <adam.wudzinski@nokia.com> | 2019-03-26 16:47:06 +0100 |
commit | b0f2f345cc2d1cc3812ad8a06fc1898daf5842d0 (patch) | |
tree | e6022e92e026a02912548e313ff2a02b5c27ddec /test/app/vnfSearch/VnfSearchActions.test.js | |
parent | b2c7546f9027099161aeaf5791f1d0f3a52b92d2 (diff) |
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 <adam.wudzinski@nokia.com>
Diffstat (limited to 'test/app/vnfSearch/VnfSearchActions.test.js')
-rw-r--r-- | test/app/vnfSearch/VnfSearchActions.test.js | 215 |
1 files changed, 215 insertions, 0 deletions
diff --git a/test/app/vnfSearch/VnfSearchActions.test.js b/test/app/vnfSearch/VnfSearchActions.test.js new file mode 100644 index 0000000..e1c3733 --- /dev/null +++ b/test/app/vnfSearch/VnfSearchActions.test.js @@ -0,0 +1,215 @@ +import configureStore from 'redux-mock-store'; +import thunk from 'redux-thunk' +import fetchMock from 'fetch-mock'; + +import { + processVnfFilterPanelCollapse, + clearVnfSearchData, + setNotificationText, + processVnfVisualizationsOnFilterChange +} from 'app/vnfSearch/VnfSearchActions.js'; +import { + vnfActionTypes, + CHART_PROV_STATUS, + CHART_ORCH_STATUS, + CHART_NF_TYPE, + CHART_NF_ROLE, + TOTAL_VNF_COUNT, + VNF_FILTER_EMPTY_RESULT +} from 'app/vnfSearch/VnfSearchConstants.js'; +import { globalInlineMessageBarActionTypes } from 'app/globalInlineMessageBar/GlobalInlineMessageBarConstants.js'; +import { ERROR_RETRIEVING_DATA } from 'app/networking/NetworkConstants.js'; + +describe('VnfSearchAction - Action Tests', () => { + it('Action: processVnfFilterPanelCollapse - open', () => { + const result = processVnfFilterPanelCollapse(true); + expect(result).toEqual({ + type: vnfActionTypes.VNF_FILTER_PANEL_TOGGLED, + data: { + vnfVisualizationPanelClass: 'collapsible-panel-main-panel vertical-filter-panel-is-open' + } + }); + }); + + it('Action: processVnfFilterPanelCollapse - close', () => { + const result = processVnfFilterPanelCollapse(false); + expect(result).toEqual({ + type: vnfActionTypes.VNF_FILTER_PANEL_TOGGLED, + data: { + vnfVisualizationPanelClass: 'collapsible-panel-main-panel' + } + }); + }); + + it('Action: clearVnfSearchData', () => { + const result = clearVnfSearchData(); + expect(result).toEqual({ + type: vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED, + data: { + count: '', + provStatusData: CHART_PROV_STATUS.emptyData, + orchStatusData: CHART_ORCH_STATUS.emptyData, + nfTypeData: CHART_NF_TYPE.emptyData, + nfRoleData: CHART_NF_ROLE.emptyData + } + }); + }); + + it('Action: setNotificationText - with message', () => { + const middlewares = [thunk]; + const mockStore = configureStore(middlewares); + const store = mockStore({ vnfSearch: {} }); + store.dispatch(setNotificationText('test error message', 'WARNING')); + const actions = store.getActions(); + expect(actions).toEqual([{ + type: globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE, + data: { + msgText: 'test error message', + msgSeverity: 'WARNING' + } + }]); + }); + + it('Action: processVnfVisualizationsOnFilterChange - data for filter values', () => { + const middlewares = [thunk]; + const mockStore = configureStore(middlewares); + const store = mockStore({ vnfSearch: {} }); + const filterValueMap = { + 1: 'Running', + 2: 'Junk', + 7: 'Blah', + 8: 'Doh' + }; + const expectedActions = [ + { type: vnfActionTypes.VNF_ACTIVATE_BUSY_FEEDBACK }, + { type: globalInlineMessageBarActionTypes.CLEAR_GLOBAL_MESSAGE }, + { + type: vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED, + data: { + count: 10, + provStatusData: { + values: [ + { x: 'junk', y: 10 } + ] + }, + orchStatusData: { + values: [ + { x: 'running', y: 10 } + ] + }, + nfTypeData: { + values: [ + { x: 'doh', y: 10 } + ] + }, + nfRoleData: { + values: [ + { x: 'blah', y: 10 } + ] + } + } + }, + { type: vnfActionTypes.VNF_DISABLE_BUSY_FEEDBACK } + ]; + fetchMock.mock('*', { + "total": 10, + "aggregations":{ + "nf-role":[{"doc_count":10,"key":"blah"}], + "nf-type":[{"doc_count":10,"key":"doh"}], + "prov-status":[{"doc_count":10,"key":"junk"}], + "orchestration-status":[{"doc_count":10,"key":"running"}] + } + }); + + return store.dispatch(processVnfVisualizationsOnFilterChange(filterValueMap)) + .then( () => { + const actions = store.getActions(); + expect(actions).toEqual(expectedActions); + fetchMock.restore(); + }); + }); + + it('Action: processVnfVisualizationsOnFilterChange - no data for filter values', () => { + const middlewares = [thunk]; + const mockStore = configureStore(middlewares); + const store = mockStore({ vnfSearch: {} }); + const filterValueMap = { + 1: 'Running', + 2: 'Junk', + 7: '', + 8: 'Doh' + }; + const expectedActions = [ + { type: vnfActionTypes.VNF_ACTIVATE_BUSY_FEEDBACK }, + { type: globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE, + data: { msgSeverity: "warning", msgText: VNF_FILTER_EMPTY_RESULT } + }, + { + type: vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED, + data: { + count: TOTAL_VNF_COUNT.emptyData, + provStatusData: CHART_PROV_STATUS.emptyData, + orchStatusData: CHART_ORCH_STATUS.emptyData, + nfTypeData: CHART_NF_TYPE.emptyData, + nfRoleData: CHART_NF_ROLE.emptyData + } + }, + { type: vnfActionTypes.VNF_DISABLE_BUSY_FEEDBACK } + ]; + fetchMock.mock('*', { + "total": 0, + "aggregations":{ + "nf-role":[], + "nf-type":[], + "prov-status":[], + "orchestration-status":[] + } + }); + + return store.dispatch(processVnfVisualizationsOnFilterChange(filterValueMap)) + .then( () => { + const actions = store.getActions(); + expect(actions).toEqual(expectedActions); + fetchMock.restore(); + }); + }); + + it('Action: processVnfVisualizationsOnFilterChange - network error', () => { + const middlewares = [thunk]; + const mockStore = configureStore(middlewares); + const store = mockStore({ vnfSearch: {} }); + const filterValueMap = { + 1: 'Running', + 2: 'Junk', + 7: 'Blah', + 8: 'Doh' + }; + const expectedActions = [ + { type: vnfActionTypes.VNF_ACTIVATE_BUSY_FEEDBACK }, + { type: vnfActionTypes.VNF_DISABLE_BUSY_FEEDBACK }, + { + type: vnfActionTypes.VNF_NETWORK_ERROR, + data: { errorMsg: ERROR_RETRIEVING_DATA } + } + ]; + fetchMock.mock('*', 503); + + return store.dispatch(processVnfVisualizationsOnFilterChange(filterValueMap)) + .then( () => { + const actions = store.getActions(); + expect(actions).toEqual(expectedActions); + fetchMock.restore(); + }); + }); + + it('Action: setNotificationText - no message', () => { + const middlewares = [thunk]; + const mockStore = configureStore(middlewares); + const store = mockStore({ vnfSearch: {} }); + store.dispatch(setNotificationText('', '')); + const actions = store.getActions(); + expect(actions).toEqual([{ + type: globalInlineMessageBarActionTypes.CLEAR_GLOBAL_MESSAGE + }]); + }); +}) |