addIntegration.spec.jsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* global global */
  2. import {mountWithTheme} from 'sentry-test/enzyme';
  3. import AddIntegration from 'sentry/views/organizationIntegrations/addIntegration';
  4. describe('AddIntegration', function () {
  5. const provider = TestStubs.GitHubIntegrationProvider();
  6. const integration = TestStubs.GitHubIntegration();
  7. it('Adds an integration on dialog completion', function () {
  8. const onAdd = jest.fn();
  9. const focus = jest.fn();
  10. const open = jest.fn().mockReturnValue({focus});
  11. global.open = open;
  12. const wrapper = mountWithTheme(
  13. <AddIntegration provider={provider} onInstall={onAdd}>
  14. {onClick => (
  15. <a href="#" onClick={onClick}>
  16. Click
  17. </a>
  18. )}
  19. </AddIntegration>
  20. );
  21. const newIntegration = {
  22. source: null,
  23. origin: 'http://localhost',
  24. data: {
  25. success: true,
  26. data: Object.assign({}, integration, {
  27. id: '2',
  28. domain_name: 'new-integration.github.com',
  29. icon: 'http://example.com/new-integration-icon.png',
  30. name: 'New Integration',
  31. }),
  32. },
  33. };
  34. wrapper.instance().didReceiveMessage(newIntegration);
  35. expect(onAdd).toHaveBeenCalledWith(newIntegration.data.data);
  36. });
  37. });