stateSaveEpic.test.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { epicTester } from 'test/core/redux/epicTester';
  2. import { stateSaveEpic } from './stateSaveEpic';
  3. import { stateSaveAction, setUrlReplacedAction } from '../actionTypes';
  4. import { updateLocation } from 'app/core/actions/location';
  5. import { mockExploreState } from 'test/mocks/mockExploreState';
  6. describe('stateSaveEpic', () => {
  7. describe('when stateSaveAction is dispatched', () => {
  8. describe('and there is a left state', () => {
  9. describe('and no split', () => {
  10. it('then the correct actions are dispatched', () => {
  11. const { exploreId, state } = mockExploreState();
  12. epicTester(stateSaveEpic, state)
  13. .whenActionIsDispatched(stateSaveAction())
  14. .thenResultingActionsEqual(
  15. updateLocation({
  16. query: { left: '["now-6h","now","test",{"ui":[true,true,true,null]}]' },
  17. replace: true,
  18. }),
  19. setUrlReplacedAction({ exploreId })
  20. );
  21. });
  22. });
  23. describe('and explore is splitted', () => {
  24. it('then the correct actions are dispatched', () => {
  25. const { exploreId, state } = mockExploreState({ split: true });
  26. epicTester(stateSaveEpic, state)
  27. .whenActionIsDispatched(stateSaveAction())
  28. .thenResultingActionsEqual(
  29. updateLocation({
  30. query: {
  31. left: '["now-6h","now","test",{"ui":[true,true,true,null]}]',
  32. right: '["now-6h","now","test",{"ui":[true,true,true,null]}]',
  33. },
  34. replace: true,
  35. }),
  36. setUrlReplacedAction({ exploreId })
  37. );
  38. });
  39. });
  40. });
  41. describe('and urlReplaced is true', () => {
  42. it('then setUrlReplacedAction should not be dispatched', () => {
  43. const { state } = mockExploreState({ urlReplaced: true });
  44. epicTester(stateSaveEpic, state)
  45. .whenActionIsDispatched(stateSaveAction())
  46. .thenResultingActionsEqual(
  47. updateLocation({
  48. query: { left: '["now-6h","now","test",{"ui":[true,true,true,null]}]' },
  49. replace: false,
  50. })
  51. );
  52. });
  53. });
  54. });
  55. });