stateSaveEpic.test.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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: { orgId: '1', left: '["now-6h","now","test",{"mode":null},{"ui":[true,true,true,null]}]' },
  17. replace: true,
  18. }),
  19. setUrlReplacedAction({ exploreId })
  20. );
  21. });
  22. });
  23. describe('and explore is split', () => {
  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. orgId: '1',
  32. left: '["now-6h","now","test",{"mode":null},{"ui":[true,true,true,null]}]',
  33. right: '["now-6h","now","test",{"mode":null},{"ui":[true,true,true,null]}]',
  34. },
  35. replace: true,
  36. }),
  37. setUrlReplacedAction({ exploreId })
  38. );
  39. });
  40. });
  41. });
  42. describe('and urlReplaced is true', () => {
  43. it('then setUrlReplacedAction should not be dispatched', () => {
  44. const { state } = mockExploreState({ urlReplaced: true });
  45. epicTester(stateSaveEpic, state)
  46. .whenActionIsDispatched(stateSaveAction())
  47. .thenResultingActionsEqual(
  48. updateLocation({
  49. query: { orgId: '1', left: '["now-6h","now","test",{"mode":null},{"ui":[true,true,true,null]}]' },
  50. replace: false,
  51. })
  52. );
  53. });
  54. });
  55. });
  56. });