123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- import {mountWithTheme} from 'sentry-test/enzyme';
- import ExternalIssueActions from 'sentry/components/group/externalIssueActions';
- describe('ExternalIssueActions', function () {
- const group = TestStubs.Group();
- describe('with no external issues linked', function () {
- const integration = TestStubs.GitHubIntegration({externalIssues: []});
- const configurations = [integration];
- const wrapper = mountWithTheme(
- <ExternalIssueActions
- key="github"
- group={group}
- configurations={configurations}
- onChange={() => {}}
- />
- );
- // console.log(configurations);
- it('renders', function () {
- expect(wrapper).toSnapshot();
- });
- it('renders GitHub Issue when no issues currently linked', function () {
- expect(wrapper.find('IntegrationLink a').text()).toEqual('GitHub Issue');
- });
- it('should not have `+` icon', function () {
- const container = wrapper.find('IssueSyncListElementContainer').first();
- expect(container.contains('StyledIcon')).toBe(false);
- });
- describe('opens modal', function () {
- MockApiClient.addMockResponse({
- url: '/groups/1/integrations/1/?action=create',
- body: {createIssueConfig: []},
- });
- it('opens when clicking text', function () {
- wrapper.find('IntegrationLink a').simulate('click');
- expect(wrapper.find('Hovercard').first().prop('header')).toEqual(
- 'GitHub Integration'
- );
- });
- });
- });
- describe('with an external issue linked', function () {
- const externalIssues = [
- {
- id: 100,
- url: 'https://github.com/MeredithAnya/testing/issues/2',
- key: 'getsentry/sentry#2',
- },
- ];
- const integration = TestStubs.GitHubIntegration({externalIssues});
- const configurations = [integration];
- const wrapper = mountWithTheme(
- <ExternalIssueActions
- key="github"
- group={group}
- configurations={configurations}
- onChange={() => {}}
- />
- );
- it('renders', function () {
- expect(wrapper.find('IssueSyncElement')).toHaveLength(0);
- });
- it('renders GitHub Issue when no issues currently linked', function () {
- expect(wrapper.find('IntegrationLink a').text()).toEqual('getsentry/sentry#2');
- });
- describe('deletes linked issue', function () {
- const mockDelete = MockApiClient.addMockResponse({
- url: '/groups/1/integrations/1/?externalIssue=100',
- method: 'DELETE',
- });
- it('deletes when clicking x', function () {
- wrapper.find('StyledIcon').simulate('click');
- expect(mockDelete).toHaveBeenCalled();
- });
- });
- });
- });
|