index.spec.tsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import OrganizationActivity from 'sentry/views/organizationActivity';
  4. describe('OrganizationActivity', function () {
  5. const {router, organization, routerContext} = initializeOrg();
  6. let params = {};
  7. beforeEach(function () {
  8. MockApiClient.addMockResponse({
  9. url: '/organizations/org-slug/activity/',
  10. body: [
  11. TestStubs.ActivityFeed(),
  12. TestStubs.ActivityFeed({
  13. id: '49',
  14. data: {},
  15. type: 'set_public',
  16. }),
  17. ],
  18. });
  19. params = {
  20. ...router,
  21. params: {
  22. orgId: organization.slug,
  23. },
  24. };
  25. });
  26. it('renders', function () {
  27. render(<OrganizationActivity {...params} />, {context: routerContext});
  28. expect(screen.getAllByTestId('activity-feed-item')).toHaveLength(2);
  29. });
  30. it('renders empty', function () {
  31. MockApiClient.addMockResponse({
  32. url: '/organizations/org-slug/activity/',
  33. body: [],
  34. });
  35. render(<OrganizationActivity {...params} />, {context: routerContext});
  36. expect(screen.queryByTestId('activity-feed-item')).not.toBeInTheDocument();
  37. expect(screen.getByTestId('empty-state')).toBeInTheDocument();
  38. });
  39. it('renders not found', function () {
  40. MockApiClient.addMockResponse({
  41. url: '/organizations/org-slug/activity/',
  42. body: [],
  43. statusCode: 404,
  44. });
  45. render(<OrganizationActivity {...params} />, {context: routerContext});
  46. expect(screen.queryByTestId('activity-feed-item')).not.toBeInTheDocument();
  47. expect(screen.getByTestId('empty-state')).toBeInTheDocument();
  48. });
  49. });