acceptProjectTransfer.spec.jsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import React from 'react';
  2. import {mountWithTheme} from 'sentry-test/enzyme';
  3. import AcceptProjectTransfer from 'app/views/acceptProjectTransfer';
  4. jest.mock('jquery');
  5. describe('AcceptProjectTransfer', function() {
  6. let getMock;
  7. let postMock;
  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. mountWithTheme(
  27. <AcceptProjectTransfer
  28. location={{
  29. pathame: 'endpoint',
  30. query: {data: 'XYZ'},
  31. }}
  32. />,
  33. TestStubs.routerContext()
  34. );
  35. expect(getMock).toHaveBeenCalled();
  36. });
  37. it('submits', function() {
  38. const wrapper = mountWithTheme(
  39. <AcceptProjectTransfer
  40. location={{
  41. pathame: 'endpoint',
  42. query: {data: 'XYZ'},
  43. }}
  44. />,
  45. TestStubs.routerContext()
  46. );
  47. wrapper.find('form').simulate('submit');
  48. expect(postMock).toHaveBeenCalledWith(
  49. endpoint,
  50. expect.objectContaining({
  51. method: 'POST',
  52. })
  53. );
  54. });
  55. });