index.spec.tsx 1.3 KB

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