2018-10-24 10:23:11 +02:00
|
|
|
import { appNotificationsReducer } from './appNotification';
|
|
|
|
|
import { ActionTypes } from '../actions/appNotification';
|
2018-10-24 14:33:53 +02:00
|
|
|
import { AppNotificationSeverity, AppNotificationTimeout } from 'app/types/';
|
2018-10-22 14:22:40 +02:00
|
|
|
|
|
|
|
|
describe('clear alert', () => {
|
|
|
|
|
it('should filter alert', () => {
|
2018-10-23 16:00:04 +02:00
|
|
|
const id1 = 1540301236048;
|
|
|
|
|
const id2 = 1540301248293;
|
|
|
|
|
|
2018-10-22 14:22:40 +02:00
|
|
|
const initialState = {
|
2018-10-23 16:00:04 +02:00
|
|
|
appNotifications: [
|
2018-10-22 14:22:40 +02:00
|
|
|
{
|
2018-10-23 16:00:04 +02:00
|
|
|
id: id1,
|
2018-10-24 10:18:28 +02:00
|
|
|
severity: AppNotificationSeverity.Success,
|
2018-10-22 14:22:40 +02:00
|
|
|
icon: 'success',
|
|
|
|
|
title: 'test',
|
|
|
|
|
text: 'test alert',
|
2018-10-24 14:33:53 +02:00
|
|
|
timeout: AppNotificationTimeout.Success,
|
2018-10-22 14:22:40 +02:00
|
|
|
},
|
|
|
|
|
{
|
2018-10-23 16:00:04 +02:00
|
|
|
id: id2,
|
2018-10-24 10:18:28 +02:00
|
|
|
severity: AppNotificationSeverity.Warning,
|
2018-10-22 14:22:40 +02:00
|
|
|
icon: 'warning',
|
|
|
|
|
title: 'test2',
|
|
|
|
|
text: 'test alert fail 2',
|
2018-10-24 14:33:53 +02:00
|
|
|
timeout: AppNotificationTimeout.Warning,
|
2018-10-22 14:22:40 +02:00
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-23 16:00:04 +02:00
|
|
|
const result = appNotificationsReducer(initialState, {
|
2018-10-23 13:34:27 +02:00
|
|
|
type: ActionTypes.ClearAppNotification,
|
2018-10-23 16:00:04 +02:00
|
|
|
payload: id2,
|
2018-10-22 14:22:40 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const expectedResult = {
|
2018-10-23 16:00:04 +02:00
|
|
|
appNotifications: [
|
2018-10-22 14:22:40 +02:00
|
|
|
{
|
2018-10-23 16:00:04 +02:00
|
|
|
id: id1,
|
2018-10-24 10:18:28 +02:00
|
|
|
severity: AppNotificationSeverity.Success,
|
2018-10-22 14:22:40 +02:00
|
|
|
icon: 'success',
|
|
|
|
|
title: 'test',
|
|
|
|
|
text: 'test alert',
|
2018-10-24 14:33:53 +02:00
|
|
|
timeout: AppNotificationTimeout.Success,
|
2018-10-22 14:22:40 +02:00
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
expect(result).toEqual(expectedResult);
|
|
|
|
|
});
|
|
|
|
|
});
|