teamAccessRequestModal.spec.jsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import TeamAccessRequestModal from 'app/components/modals/teamAccessRequestModal';
  3. describe('TeamAccessRequestModal', function () {
  4. let wrapper;
  5. let createMock;
  6. const closeModal = jest.fn();
  7. const onClose = jest.fn();
  8. const orgId = TestStubs.Organization().slug;
  9. const memberId = TestStubs.Member().id;
  10. const teamId = TestStubs.Team().slug;
  11. const modalRenderProps = {
  12. Body: p => p.children,
  13. Footer: p => p.children,
  14. Header: p => p.children,
  15. closeModal,
  16. onClose,
  17. };
  18. beforeEach(function () {
  19. MockApiClient.clearMockResponses();
  20. wrapper = mountWithTheme(
  21. <TeamAccessRequestModal
  22. orgId={orgId}
  23. teamId={teamId}
  24. memberId={memberId}
  25. {...modalRenderProps}
  26. />,
  27. TestStubs.routerContext()
  28. );
  29. createMock = MockApiClient.addMockResponse({
  30. url: `/organizations/${orgId}/members/${memberId}/teams/${teamId}/`,
  31. method: 'POST',
  32. });
  33. });
  34. it('renders', function () {
  35. expect(wrapper.find('Body').text()).toBe(
  36. `You do not have permission to add members to the #${teamId} team, but we will send a request to your organization admins for approval.`
  37. );
  38. });
  39. it('creates access request on continue', function () {
  40. wrapper.find('button[aria-label="Continue"]').simulate('click');
  41. expect(createMock).toHaveBeenCalled();
  42. });
  43. it('closes modal on cancel', function () {
  44. wrapper.find('button[aria-label="Cancel"]').simulate('click');
  45. expect(createMock).not.toHaveBeenCalled();
  46. expect(closeModal).toHaveBeenCalled();
  47. });
  48. });