summaryrefslogtreecommitdiffstats
path: root/src/generic-components
diff options
context:
space:
mode:
authorbogumil_zebek <bogumil.zebek@nokia.com>2018-09-20 09:23:34 +0200
committerbogumil_zebek <bogumil.zebek@nokia.com>2018-09-20 09:24:46 +0200
commit7eed2ed1366bece336b0d2e28ac8b3d4526964df (patch)
treeb81ffeb3e063f1759e75f720a15b03375f7caf42 /src/generic-components
parenta76f517ed1989952fa896ec1fb919fcc12dd0cd7 (diff)
Add tests to notifications module
Issue-ID: AAI-1640 Change-Id: I69bee609539e3977996f9eb2bfc821432028464b Signed-off-by: bogumil_zebek <bogumil.zebek@nokia.com>
Diffstat (limited to 'src/generic-components')
-rw-r--r--src/generic-components/notifications/NotificationReducer.js59
1 files changed, 22 insertions, 37 deletions
diff --git a/src/generic-components/notifications/NotificationReducer.js b/src/generic-components/notifications/NotificationReducer.js
index e20a8fb..1f5122c 100644
--- a/src/generic-components/notifications/NotificationReducer.js
+++ b/src/generic-components/notifications/NotificationReducer.js
@@ -21,43 +21,28 @@
import NotificationConstants from './NotificationConstants.js';
export default (state = null, action) => {
- switch (action.type) {
- case NotificationConstants.NOTIFY_INFO:
- return {
- type: 'default',
- title: action.data.title,
- msg: action.data.msg,
- timeout: action.data.timeout
- };
-
- case NotificationConstants.NOTIFY_ERROR:
- return {
- type: 'error',
- title: action.data.title,
- msg: action.data.msg,
- timeout: action.data.timeout
- };
-
- case NotificationConstants.NOTIFY_WARNING:
- return {
- type: 'warning',
- title: action.data.title,
- msg: action.data.msg,
- timeout: action.data.timeout
- };
-
- case NotificationConstants.NOTIFY_SUCCESS:
- return {
- type: 'success',
+ switch (action.type) {
+ case NotificationConstants.NOTIFY_INFO:
+ return createStatus('default', action);
+ case NotificationConstants.NOTIFY_ERROR:
+ return createStatus('error', action);
+ case NotificationConstants.NOTIFY_WARNING:
+ return createStatus('warning', action);
+ case NotificationConstants.NOTIFY_SUCCESS:
+ return createStatus('success', action);
+ case NotificationConstants.NOTIFY_CLOSE:
+ return null;
+ default:
+ return state;
+ }
+
+};
+
+function createStatus(type, action) {
+ return {
+ type: type,
title: action.data.title,
msg: action.data.msg,
timeout: action.data.timeout
- };
- case NotificationConstants.NOTIFY_CLOSE:
- return null;
-
- default:
- return state;
- }
-
-};
+ };
+}