customCommitsResolutionModal.spec.jsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import selectEvent from 'react-select-event';
  2. import {Commit} from 'fixtures/js-stubs/commit';
  3. import {act, render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  4. import CustomCommitsResolutionModal from 'sentry/components/customCommitsResolutionModal';
  5. describe('CustomCommitsResolutionModal', function () {
  6. let commitsMock;
  7. beforeEach(function () {
  8. commitsMock = MockApiClient.addMockResponse({
  9. url: '/projects/org-slug/project-slug/commits/',
  10. body: [Commit()],
  11. });
  12. });
  13. it('can select a commit', async function () {
  14. const onSelected = jest.fn();
  15. render(
  16. <CustomCommitsResolutionModal
  17. Header={p => p.children}
  18. Body={p => p.children}
  19. Footer={p => p.children}
  20. orgSlug="org-slug"
  21. projectSlug="project-slug"
  22. onSelected={onSelected}
  23. closeModal={jest.fn()}
  24. />
  25. );
  26. await act(tick);
  27. expect(commitsMock).toHaveBeenCalled();
  28. await selectEvent.select(screen.getByText('e.g. d86b832'), 'f7f395d14b2f');
  29. userEvent.click(screen.getByRole('button', {name: 'Save Changes'}));
  30. expect(onSelected).toHaveBeenCalledWith({
  31. inCommit: {
  32. commit: 'f7f395d14b2fe29a4e253bf1d3094d61e6ad4434',
  33. repository: 'example/repo-name',
  34. },
  35. });
  36. });
  37. });