addIntegrationButton.spec.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. /* global global */
  2. import {GitHubIntegrationProviderFixture} from 'sentry-fixture/githubIntegrationProvider';
  3. import {OrganizationFixture} from 'sentry-fixture/organization';
  4. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  5. import {AddIntegrationButton} from 'sentry/views/settings/organizationIntegrations/addIntegrationButton';
  6. describe('AddIntegrationButton', function () {
  7. const provider = GitHubIntegrationProviderFixture();
  8. it('Opens the setup dialog on click', async function () {
  9. const focus = jest.fn();
  10. const open = jest.fn().mockReturnValue({focus, close: jest.fn()});
  11. // any is needed here because getSentry has different types for global
  12. (global as any).open = open;
  13. render(
  14. <AddIntegrationButton
  15. provider={provider}
  16. onAddIntegration={jest.fn()}
  17. organization={OrganizationFixture()}
  18. />
  19. );
  20. await userEvent.click(screen.getByLabelText('Add integration'));
  21. expect(open.mock.calls).toHaveLength(1);
  22. expect(focus.mock.calls).toHaveLength(1);
  23. expect(open.mock.calls[0][2]).toBe(
  24. 'scrollbars=yes,width=100,height=100,top=334,left=462'
  25. );
  26. });
  27. });