2 * Copyright © 2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 import notificationsReducer from 'shared/notifications/notificationsReducer';
17 import { actionTypes } from 'shared/notifications/notificationsConstants';
19 describe('Notifications Reducer', () => {
20 it('Returns empty state array', () => {
21 expect(notificationsReducer(undefined, {})).toEqual([]);
23 it('Add notification obj to the notification arr in store', () => {
25 type: actionTypes.ADD_NOTIFICATION,
27 title: 'Notification1',
28 message: 'This is a test',
30 id: '4a2b0038-e442-4ccb-b577-5d04eee6fdfb',
34 expect(notificationsReducer([], action)).toEqual([action.payload]);
36 it('Remove notification instance from store', () => {
39 title: 'Notification1',
40 message: 'This is a test',
42 id: '4a2b0038-e442-4ccb-b577-5d04eee6fdfb',
46 const removeAction = {
47 type: actionTypes.REMOVE_NOTIFICATION,
49 title: 'Notification1',
50 message: 'This is a test',
52 id: '4a2b0038-e442-4ccb-b577-5d04eee6fdfb',
56 expect(notificationsReducer([], removeAction)).toEqual([]);
57 expect(notificationsReducer(resultState, removeAction)).toEqual(
58 resultState.filter(item => item.id !== removeAction.payload.id)