reducers.test.ts 880 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { alertsReducer } from './reducers';
  2. import { ActionTypes } from './actions';
  3. describe('clear alert', () => {
  4. it('should filter alert', () => {
  5. const initialState = {
  6. alerts: [
  7. {
  8. severity: 'success',
  9. icon: 'success',
  10. title: 'test',
  11. text: 'test alert',
  12. },
  13. {
  14. severity: 'fail',
  15. icon: 'warning',
  16. title: 'test2',
  17. text: 'test alert fail 2',
  18. },
  19. ],
  20. };
  21. const result = alertsReducer(initialState, {
  22. type: ActionTypes.ClearAppNotification,
  23. payload: initialState.alerts[1],
  24. });
  25. const expectedResult = {
  26. alerts: [
  27. {
  28. severity: 'success',
  29. icon: 'success',
  30. title: 'test',
  31. text: 'test alert',
  32. },
  33. ],
  34. };
  35. expect(result).toEqual(expectedResult);
  36. });
  37. });