integrationDetailsModal.spec.jsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import React from 'react';
  2. import {mount} from 'enzyme';
  3. import IntegrationDetailsModal from 'app/components/modals/integrationDetailsModal';
  4. import HookStore from 'app/stores/hookStore';
  5. describe('IntegrationDetailsModal', function() {
  6. const integrationAdded = jest.fn();
  7. const org = TestStubs.Organization();
  8. const routerContext = TestStubs.routerContext();
  9. it('renders simple integration', function() {
  10. const onClose = jest.fn();
  11. const provider = TestStubs.GitHubIntegrationProvider();
  12. const wrapper = mount(
  13. <IntegrationDetailsModal
  14. provider={provider}
  15. closeModal={onClose}
  16. organization={org}
  17. onAddIntegration={integrationAdded}
  18. />,
  19. routerContext
  20. );
  21. expect(wrapper).toMatchSnapshot();
  22. wrapper
  23. .find('Button')
  24. .first()
  25. .simulate('click');
  26. expect(onClose).toHaveBeenCalled();
  27. });
  28. it('renders link for non-addable integration', function() {
  29. const onClose = jest.fn();
  30. const provider = TestStubs.JiraIntegrationProvider();
  31. const wrapper = mount(
  32. <IntegrationDetailsModal
  33. provider={provider}
  34. closeModal={onClose}
  35. organization={org}
  36. onAddIntegration={integrationAdded}
  37. />,
  38. routerContext
  39. );
  40. expect(wrapper.find('Button[external]').exists()).toBe(true);
  41. });
  42. it('disables the button via a hookstore IntegrationFeatures component', function() {
  43. HookStore.add('integrations:feature-gates', () => ({
  44. FeatureList: p => null,
  45. IntegrationFeatures: p =>
  46. p.children({
  47. disabled: true,
  48. disabledReason: 'Integration disabled',
  49. ungatedFeatures: p.features,
  50. gatedFeatureGroups: [],
  51. }),
  52. }));
  53. const provider = TestStubs.GitHubIntegrationProvider();
  54. const wrapper = mount(
  55. <IntegrationDetailsModal
  56. provider={provider}
  57. onAddIntegration={integrationAdded}
  58. organization={org}
  59. closeModal={() => null}
  60. />,
  61. routerContext
  62. );
  63. expect(wrapper.find('Button[disabled]').exists()).toBe(true);
  64. expect(wrapper.find('DisabledNotice').text()).toBe('Integration disabled');
  65. });
  66. });