reducers.test.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { appNotificationsReducer } from './reducers';
  2. import { ActionTypes } from './actions';
  3. import { AppNotificationSeverity } 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. },
  17. {
  18. id: id2,
  19. severity: AppNotificationSeverity.Warning,
  20. icon: 'warning',
  21. title: 'test2',
  22. text: 'test alert fail 2',
  23. },
  24. ],
  25. };
  26. const result = appNotificationsReducer(initialState, {
  27. type: ActionTypes.ClearAppNotification,
  28. payload: id2,
  29. });
  30. const expectedResult = {
  31. appNotifications: [
  32. {
  33. id: id1,
  34. severity: AppNotificationSeverity.Success,
  35. icon: 'success',
  36. title: 'test',
  37. text: 'test alert',
  38. },
  39. ],
  40. };
  41. expect(result).toEqual(expectedResult);
  42. });
  43. });