acceptProjectTransfer.spec.jsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  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. mountWithTheme(
  25. <AcceptProjectTransfer
  26. location={{
  27. pathname: 'endpoint',
  28. query: {data: 'XYZ'},
  29. }}
  30. />,
  31. TestStubs.routerContext()
  32. );
  33. expect(getMock).toHaveBeenCalled();
  34. });
  35. it('submits', function () {
  36. const wrapper = mountWithTheme(
  37. <AcceptProjectTransfer
  38. location={{
  39. pathname: 'endpoint',
  40. query: {data: 'XYZ'},
  41. }}
  42. />,
  43. TestStubs.routerContext()
  44. );
  45. wrapper.find('form').simulate('submit');
  46. expect(postMock).toHaveBeenCalledWith(
  47. endpoint,
  48. expect.objectContaining({
  49. method: 'POST',
  50. })
  51. );
  52. });
  53. });