index.spec.tsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import {render} from 'sentry-test/reactTestingLibrary';
  2. import {RouteContext} from 'sentry/views/routeContext';
  3. import SharedGroupDetails from 'sentry/views/sharedGroupDetails';
  4. describe('SharedGroupDetails', function () {
  5. const eventEntry = TestStubs.EventEntry();
  6. const exception = TestStubs.EventStacktraceException().entries[0];
  7. const params = {shareId: 'a'};
  8. const router = TestStubs.router({params});
  9. beforeEach(function () {
  10. MockApiClient.addMockResponse({
  11. url: '/organizations/org-slug/shared/issues/a/',
  12. body: TestStubs.Group({
  13. title: 'ZeroDivisionError',
  14. latestEvent: TestStubs.Event({
  15. entries: [eventEntry, exception],
  16. }),
  17. project: TestStubs.Project({organization: {slug: 'test-org'}}),
  18. }),
  19. });
  20. MockApiClient.addMockResponse({
  21. url: '/shared/issues/a/',
  22. body: TestStubs.Group({
  23. title: 'ZeroDivisionError',
  24. latestEvent: TestStubs.Event({
  25. entries: [eventEntry, exception],
  26. }),
  27. project: TestStubs.Project({organization: {slug: 'test-org'}}),
  28. }),
  29. });
  30. });
  31. afterEach(function () {
  32. MockApiClient.clearMockResponses();
  33. });
  34. it('renders', function () {
  35. const {container} = render(
  36. <RouteContext.Provider value={{router, ...router}}>
  37. <SharedGroupDetails
  38. params={params}
  39. api={new MockApiClient()}
  40. route={{}}
  41. router={router}
  42. routes={router.routes}
  43. routeParams={router.params}
  44. location={router.location}
  45. />
  46. </RouteContext.Provider>
  47. );
  48. expect(container).toSnapshot();
  49. });
  50. it('renders with org slug in path', function () {
  51. const params_with_slug = {shareId: 'a', orgId: 'test-org'};
  52. const router_with_slug = TestStubs.router({params_with_slug});
  53. const {container} = render(
  54. <RouteContext.Provider value={{router, ...router}}>
  55. <SharedGroupDetails
  56. params={params}
  57. api={new MockApiClient()}
  58. route={{}}
  59. router={router_with_slug}
  60. routes={router_with_slug.routes}
  61. routeParams={router_with_slug.params}
  62. location={router_with_slug.location}
  63. />
  64. </RouteContext.Provider>
  65. );
  66. expect(container).toSnapshot();
  67. });
  68. });