MainScreenWrapperActionHelper test 33/85033/1
authorAdam Wudzinski <adam.wudzinski@nokia.com>
Thu, 11 Apr 2019 09:33:50 +0000 (11:33 +0200)
committerawudzins <adam.wudzinski@nokia.com>
Thu, 11 Apr 2019 09:33:50 +0000 (11:33 +0200)
Add tests for MainScreenWrapperActionHelper

Change-Id: I5bd959da5635546be6ab0761801a24b1ea1ee084
Issue-ID: AAI-1618
Signed-off-by: awudzins <adam.wudzinski@nokia.com>
test/app/MainScreenWrapperActionHelper.test.js [new file with mode: 0644]

diff --git a/test/app/MainScreenWrapperActionHelper.test.js b/test/app/MainScreenWrapperActionHelper.test.js
new file mode 100644 (file)
index 0000000..011010e
--- /dev/null
@@ -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);
+    });
+  });
+
+});

© 2017 ONAP. Copyright © The Linux Foundation ®. All Rights Reserved.
The Linux Foundation has registered trademarks and uses trademarks.
For a list of trademarks of The Linux Foundation, please see our Trademark Usage page.
Linux is a registered trademark of Linus Torvalds.
Privacy Policy and Terms of Use