useLoadReplayReader.spec.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {renderHook} from 'sentry-test/reactTestingLibrary';
  3. import useLoadReplayReader from 'sentry/utils/replays/hooks/useLoadReplayReader';
  4. import {OrganizationContext} from 'sentry/views/organizationContext';
  5. jest.mock('sentry/utils/replays/hooks/useReplayData', () => ({
  6. __esModule: true,
  7. default: () => jest.fn().mockReturnValue({}),
  8. }));
  9. const {organization, project} = initializeOrg();
  10. const wrapper = ({children}: {children?: React.ReactNode}) => (
  11. <OrganizationContext.Provider value={organization}>
  12. {children}
  13. </OrganizationContext.Provider>
  14. );
  15. describe('useLoadReplayReader', () => {
  16. beforeEach(() => {
  17. MockApiClient.clearMockResponses();
  18. });
  19. it('should accept a replaySlug with project and id parts', () => {
  20. const {result} = renderHook(useLoadReplayReader, {
  21. wrapper,
  22. initialProps: {
  23. orgSlug: organization.slug,
  24. replaySlug: `${project.slug}:123`,
  25. },
  26. });
  27. expect(result.current).toStrictEqual(
  28. expect.objectContaining({
  29. replayId: '123',
  30. })
  31. );
  32. });
  33. it('should accept a replaySlug with only the replay-id', () => {
  34. const {result} = renderHook(useLoadReplayReader, {
  35. wrapper,
  36. initialProps: {
  37. orgSlug: organization.slug,
  38. replaySlug: `123`,
  39. },
  40. });
  41. expect(result.current).toStrictEqual(
  42. expect.objectContaining({
  43. replayId: '123',
  44. })
  45. );
  46. });
  47. });