diff options
author | Adam Wudzinski <adam.wudzinski@nokia.com> | 2019-04-11 11:33:50 +0200 |
---|---|---|
committer | awudzins <adam.wudzinski@nokia.com> | 2019-04-11 11:33:50 +0200 |
commit | 8d1e8bb11b0cfe24e48cdd2e96dde74a8a70f77c (patch) | |
tree | 9cf7ab8bf78dfc0fca5aa59b092ea98a3bd771d2 | |
parent | 6a47c2493c21c09df35df1f9f03474f8c2f8874a (diff) |
MainScreenWrapperActionHelper test
Add tests for MainScreenWrapperActionHelper
Change-Id: I5bd959da5635546be6ab0761801a24b1ea1ee084
Issue-ID: AAI-1618
Signed-off-by: awudzins <adam.wudzinski@nokia.com>
-rw-r--r-- | test/app/MainScreenWrapperActionHelper.test.js | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/test/app/MainScreenWrapperActionHelper.test.js b/test/app/MainScreenWrapperActionHelper.test.js new file mode 100644 index 0000000..011010e --- /dev/null +++ b/test/app/MainScreenWrapperActionHelper.test.js @@ -0,0 +1,132 @@ +import configureStore from 'redux-mock-store'; +import thunk from 'redux-thunk' +import { + windowResize, + showMainMenu, + extensibleViewMessageCallback, + clearExtensibleViewData, + setSecondaryTitle +} from 'app/MainScreenWrapperActionHelper'; +import { + getSetGlobalMessageEvent, + getClearGlobalMessageEvent +} from 'app/globalInlineMessageBar/GlobalInlineMessageBarActions'; +import { + globalInlineMessageBarActionTypes +} from 'app/globalInlineMessageBar/GlobalInlineMessageBarConstants'; +import {aaiActionTypes} from 'app/MainScreenWrapperConstants'; + +const mockStore = configureStore([thunk]); + +describe('MainScreenWrapperActionHelper', () => { + let store; + + beforeEach(() => { + store = mockStore({ tierSupportReducer: {} }); + }); + + describe('windowResize', () => { + it('emits action', () => { + // Given + const expectedActions = [{ + type: aaiActionTypes.AAI_WINDOW_RESIZE + }]; + + // When + store.dispatch(windowResize()); + + // Then + expect(store.getActions()).toEqual(expectedActions); + }); + }); + + describe('showMainMenu', () => { + it('emits action with payload', () => { + // Given + const input = "testInput"; + const expectedActions = [{ + type: aaiActionTypes.AAI_SHOW_MENU, + data: { + showMenu: input + } + }]; + + // When + store.dispatch(showMainMenu(input)); + + // Then + expect(store.getActions()).toEqual(expectedActions); + }); + }); + + describe('extensibleViewMessageCallback', () => { + const msgSeverity = "msgSeverity"; + + it('emits action with payload when msgText is not blank', () => { + // Given + const msgText = "msgText"; + const expectedActions = [{ + type: globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE, + data: { + msgText: msgText, + msgSeverity: msgSeverity + } + }]; + + // When + store.dispatch(extensibleViewMessageCallback(msgText, msgSeverity)); + + // Then + expect(store.getActions()).toEqual(expectedActions); + }); + + it('emits action when msgText is blank', () => { + // Given + const msgText = ""; + const expectedActions = [{ + type: globalInlineMessageBarActionTypes.CLEAR_GLOBAL_MESSAGE + + }]; + + // When + store.dispatch(extensibleViewMessageCallback(msgText, msgSeverity)); + + // Then + expect(store.getActions()).toEqual(expectedActions); + }); + }); + + describe('clearExtensibleViewData', () => { + it('emits action with payload', () => { + // Given + const expectedActions = [{ + type: aaiActionTypes.EXTENSIBLE_VIEW_NETWORK_CALLBACK_CLEAR_DATA, + data: {} + }]; + + // When + store.dispatch(clearExtensibleViewData()); + + // Then + expect(store.getActions()).toEqual(expectedActions); + }); + }); + + describe('setSecondaryTitle', () => { + it('emits action with payload', () => { + // Given + const title = "testTitle"; + const expectedActions = [{ + type: aaiActionTypes.SET_SECONDARY_TITLE, + data: title + }]; + + // When + store.dispatch(setSecondaryTitle(title)); + + // Then + expect(store.getActions()).toEqual(expectedActions); + }); + }); + +}); |