appNotification.test.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { appNotificationsReducer } from './appNotification';
  2. import { ActionTypes } from '../actions/appNotification';
  3. import { AppNotificationSeverity, AppNotificationTimeout } from 'app/types/';
  4. describe('clear alert', () => {
  5. it('should filter alert', () => {
  6. const id1 = 1540301236048;
  7. const id2 = 1540301248293;
  8. const initialState = {
  9. appNotifications: [
  10. {
  11. id: id1,
  12. severity: AppNotificationSeverity.Success,
  13. icon: 'success',
  14. title: 'test',
  15. text: 'test alert',
  16. timeout: AppNotificationTimeout.Success,
  17. },
  18. {
  19. id: id2,
  20. severity: AppNotificationSeverity.Warning,
  21. icon: 'warning',
  22. title: 'test2',
  23. text: 'test alert fail 2',
  24. timeout: AppNotificationTimeout.Warning,
  25. },
  26. ],
  27. };
  28. const result = appNotificationsReducer(initialState, {
  29. type: ActionTypes.ClearAppNotification,
  30. payload: id2,
  31. });
  32. const expectedResult = {
  33. appNotifications: [
  34. {
  35. id: id1,
  36. severity: AppNotificationSeverity.Success,
  37. icon: 'success',
  38. title: 'test',
  39. text: 'test alert',
  40. timeout: AppNotificationTimeout.Success,
  41. },
  42. ],
  43. };
  44. expect(result).toEqual(expectedResult);
  45. });
  46. });