teamAccessRequestModal.spec.jsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import TeamAccessRequestModal from 'sentry/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. );
  28. createMock = MockApiClient.addMockResponse({
  29. url: `/organizations/${orgId}/members/${memberId}/teams/${teamId}/`,
  30. method: 'POST',
  31. });
  32. });
  33. it('renders', function () {
  34. expect(wrapper.find('Body').text()).toBe(
  35. `You do not have permission to add members to the #${teamId} team, but we will send a request to your organization admins for approval.`
  36. );
  37. });
  38. it('creates access request on continue', function () {
  39. wrapper.find('button[aria-label="Continue"]').simulate('click');
  40. expect(createMock).toHaveBeenCalled();
  41. });
  42. it('closes modal on cancel', function () {
  43. wrapper.find('button[aria-label="Cancel"]').simulate('click');
  44. expect(createMock).not.toHaveBeenCalled();
  45. expect(closeModal).toHaveBeenCalled();
  46. });
  47. });