index.spec.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  3. import AcceptProjectTransfer from 'sentry/views/acceptProjectTransfer';
  4. describe('AcceptProjectTransfer', function () {
  5. const {routerProps} = initializeOrg();
  6. let getMock: jest.Mock;
  7. let postMock: jest.Mock;
  8. const endpoint = '/accept-transfer/';
  9. beforeEach(function () {
  10. MockApiClient.clearMockResponses();
  11. getMock = MockApiClient.addMockResponse({
  12. url: '/accept-transfer/',
  13. method: 'GET',
  14. body: {
  15. project: TestStubs.Project(),
  16. organizations: [TestStubs.Organization({teams: [TestStubs.Team()]})],
  17. },
  18. });
  19. postMock = MockApiClient.addMockResponse({
  20. url: '/accept-transfer/',
  21. method: 'POST',
  22. statusCode: 204,
  23. });
  24. });
  25. it('renders', function () {
  26. render(<AcceptProjectTransfer {...routerProps} />);
  27. expect(getMock).toHaveBeenCalled();
  28. });
  29. it('submits', async function () {
  30. render(<AcceptProjectTransfer {...routerProps} />);
  31. await userEvent.click(screen.getByRole('button', {name: 'Transfer Project'}));
  32. expect(postMock).toHaveBeenCalledWith(
  33. endpoint,
  34. expect.objectContaining({
  35. method: 'POST',
  36. })
  37. );
  38. });
  39. });