issueSyncListElement.spec.jsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  2. import IssueSyncListElement from 'sentry/components/issueSyncListElement';
  3. describe('IssueSyncListElement', function () {
  4. it('renders', function () {
  5. const wrapper = render(<IssueSyncListElement integrationType="github" />);
  6. expect(wrapper.container).toSnapshot();
  7. });
  8. it('can open', function () {
  9. const onOpen = jest.fn();
  10. render(<IssueSyncListElement integrationType="github" onOpen={onOpen} />);
  11. expect(onOpen).not.toHaveBeenCalled();
  12. userEvent.click(screen.getByText('GitHub Issue'));
  13. expect(onOpen).toHaveBeenCalled();
  14. });
  15. it('can close', function () {
  16. const onClose = jest.fn();
  17. const onOpen = jest.fn();
  18. render(
  19. <IssueSyncListElement
  20. integrationType="github"
  21. externalIssueLink="github.com/issues/gh-101"
  22. externalIssueId={101}
  23. onClose={onClose}
  24. onOpen={onOpen}
  25. />
  26. );
  27. expect(onClose).not.toHaveBeenCalled();
  28. userEvent.click(screen.getByRole('button', {name: 'Close'}));
  29. expect(onClose).toHaveBeenCalled();
  30. });
  31. });