addIntegrationButton.spec.tsx 1005 B

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