acceptProjectTransfer.spec.jsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import {Organization} from 'fixtures/js-stubs/organization';
  2. import {Project} from 'fixtures/js-stubs/project';
  3. import {Team} from 'fixtures/js-stubs/team';
  4. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  5. import AcceptProjectTransfer from 'sentry/views/acceptProjectTransfer';
  6. describe('AcceptProjectTransfer', function () {
  7. let getMock;
  8. let postMock;
  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: Project(),
  17. organizations: [Organization({teams: [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(
  28. <AcceptProjectTransfer
  29. location={{
  30. pathname: 'endpoint',
  31. query: {data: 'XYZ'},
  32. }}
  33. />
  34. );
  35. expect(getMock).toHaveBeenCalled();
  36. });
  37. it('submits', function () {
  38. render(
  39. <AcceptProjectTransfer
  40. location={{
  41. pathname: 'endpoint',
  42. query: {data: 'XYZ'},
  43. }}
  44. />
  45. );
  46. userEvent.click(screen.getByRole('button', {name: 'Transfer Project'}));
  47. expect(postMock).toHaveBeenCalledWith(
  48. endpoint,
  49. expect.objectContaining({
  50. method: 'POST',
  51. })
  52. );
  53. });
  54. });