externalIssueActions.spec.jsx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import React from 'react';
  2. import {mount} from 'enzyme';
  3. import ExternalIssueActions from 'app/components/group/externalIssueActions';
  4. describe('ExternalIssueActions', function() {
  5. let group = TestStubs.Group();
  6. describe('with no external issues linked', function() {
  7. let integration = TestStubs.GitHubIntegration({externalIssues: []});
  8. let wrapper = mount(
  9. <ExternalIssueActions group={group} integration={integration} />,
  10. TestStubs.routerContext()
  11. );
  12. it('renders', function() {
  13. expect(wrapper).toMatchSnapshot();
  14. });
  15. it('renders Link GitHub Issue when no issues currently linked', function() {
  16. expect(wrapper.find('IntegrationLink a').text()).toEqual('Link GitHub Issue');
  17. });
  18. describe('opens modal', function() {
  19. MockApiClient.addMockResponse({
  20. url: '/groups/1/integrations/1/?action=create',
  21. body: {createIssueConfig: []},
  22. });
  23. it('opens when clicking text', function() {
  24. wrapper.find('IntegrationLink a').simulate('click');
  25. expect(
  26. wrapper
  27. .find('Modal')
  28. .first()
  29. .prop('show')
  30. ).toBe(true);
  31. });
  32. it('opens when clicking +', function() {
  33. wrapper.find('OpenCloseIcon').simulate('click');
  34. expect(
  35. wrapper
  36. .find('Modal')
  37. .first()
  38. .prop('show')
  39. ).toBe(true);
  40. });
  41. });
  42. });
  43. describe('with an external issue linked', function() {
  44. let externalIssues = [
  45. {
  46. id: 100,
  47. url: 'https://github.com/MeredithAnya/testing/issues/2',
  48. key: 'getsentry/sentry#2',
  49. },
  50. ];
  51. let integration = TestStubs.GitHubIntegration({externalIssues});
  52. let wrapper = mount(
  53. <ExternalIssueActions group={group} integration={integration} />,
  54. TestStubs.routerContext()
  55. );
  56. it('renders', function() {
  57. expect(wrapper.find('IssueSyncElement')).toMatchSnapshot();
  58. });
  59. it('renders Link GitHub Issue when no issues currently linked', function() {
  60. expect(wrapper.find('IntegrationLink a').text()).toEqual('getsentry/sentry#2');
  61. });
  62. describe('deletes linked issue', function() {
  63. MockApiClient.addMockResponse({
  64. url: '/groups/1/integrations/1/?externalIssue=100',
  65. method: 'DELETE',
  66. });
  67. it('deletes when clicking x', function() {
  68. wrapper.find('OpenCloseIcon').simulate('click');
  69. expect(wrapper.find('IntegrationLink a').text()).toEqual('Link GitHub Issue');
  70. });
  71. });
  72. });
  73. });