index.spec.jsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  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. const wrapper = mountWithTheme(<OrganizationActivity {...params} />, routerContext);
  28. expect(wrapper.find('ActivityItem')).toHaveLength(2);
  29. });
  30. it('renders empty', function () {
  31. MockApiClient.addMockResponse({
  32. url: '/organizations/org-slug/activity/',
  33. body: [],
  34. });
  35. const wrapper = mountWithTheme(<OrganizationActivity {...params} />, routerContext);
  36. expect(wrapper.find('ActivityItem')).toHaveLength(0);
  37. expect(wrapper.find('EmptyStateWarning')).toHaveLength(1);
  38. });
  39. it('renders not found', function () {
  40. MockApiClient.addMockResponse({
  41. url: '/organizations/org-slug/activity/',
  42. body: [],
  43. statusCode: 404,
  44. });
  45. const wrapper = mountWithTheme(<OrganizationActivity {...params} />, routerContext);
  46. expect(wrapper.find('ActivityItem')).toHaveLength(0);
  47. expect(wrapper.find('EmptyStateWarning')).toHaveLength(1);
  48. });
  49. });