123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- import React from 'react';
- import {mount} from 'enzyme';
- import IntegrationDetailsModal from 'app/components/modals/integrationDetailsModal';
- import HookStore from 'app/stores/hookStore';
- describe('IntegrationDetailsModal', function() {
- const integrationAdded = jest.fn();
- const org = TestStubs.Organization();
- const routerContext = TestStubs.routerContext();
- it('renders simple integration', function() {
- const onClose = jest.fn();
- const provider = TestStubs.GitHubIntegrationProvider();
- const wrapper = mount(
- <IntegrationDetailsModal
- provider={provider}
- closeModal={onClose}
- organization={org}
- onAddIntegration={integrationAdded}
- />,
- routerContext
- );
- expect(wrapper).toMatchSnapshot();
- wrapper
- .find('Button')
- .first()
- .simulate('click');
- expect(onClose).toHaveBeenCalled();
- });
- it('renders link for non-addable integration', function() {
- const onClose = jest.fn();
- const provider = TestStubs.JiraIntegrationProvider();
- const wrapper = mount(
- <IntegrationDetailsModal
- provider={provider}
- closeModal={onClose}
- organization={org}
- onAddIntegration={integrationAdded}
- />,
- routerContext
- );
- expect(wrapper.find('Button[external]').exists()).toBe(true);
- });
- it('disables the button via a hookstore IntegrationFeatures component', function() {
- HookStore.add('integrations:feature-gates', () => ({
- FeatureList: p => null,
- IntegrationFeatures: p =>
- p.children({
- disabled: true,
- disabledReason: 'Integration disabled',
- ungatedFeatures: p.features,
- gatedFeatureGroups: [],
- }),
- }));
- const provider = TestStubs.GitHubIntegrationProvider();
- const wrapper = mount(
- <IntegrationDetailsModal
- provider={provider}
- onAddIntegration={integrationAdded}
- organization={org}
- closeModal={() => null}
- />,
- routerContext
- );
- expect(wrapper.find('Button[disabled]').exists()).toBe(true);
- expect(wrapper.find('DisabledNotice').text()).toBe('Integration disabled');
- });
- });
|