index.spec.jsx 1.3 KB

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