processingIssueHint.spec.jsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import React from 'react';
  2. import {mount} from 'enzyme';
  3. import ProcessingIssueHint from 'app/components/stream/processingIssueHint';
  4. describe('ProcessingIssueHint', function() {
  5. let issue, wrapper;
  6. const orgId = 'test-org';
  7. const projectId = 'test-project';
  8. beforeEach(() => {
  9. issue = {
  10. hasIssues: false,
  11. hasMoreResolveableIssues: false,
  12. issuesProcessing: 0,
  13. lastSeen: '2019-01-16T15:38:38Z',
  14. numIssues: 0,
  15. resolveableIssues: 0,
  16. signedLink: null,
  17. };
  18. });
  19. describe('numIssues state', function() {
  20. beforeEach(() => {
  21. issue.numIssues = 9;
  22. wrapper = mount(
  23. <ProcessingIssueHint issue={issue} orgId={orgId} projectId={projectId} />
  24. );
  25. });
  26. it('displays a button', function() {
  27. const button = wrapper.find('Link');
  28. expect(button.length).toBe(1);
  29. expect(button.props().to).toEqual(
  30. `/settings/${orgId}/projects/${projectId}/processing-issues/`
  31. );
  32. });
  33. it('displays an icon', function() {
  34. const icon = wrapper.find('[className*="icon-alert"]');
  35. expect(icon.length).toBe(1);
  36. });
  37. it('displays text', function() {
  38. const text = wrapper.find('Container').text();
  39. expect(text).toEqual(expect.stringContaining('issues blocking'));
  40. });
  41. });
  42. describe('issuesProcessing state', function() {
  43. beforeEach(() => {
  44. issue.issuesProcessing = 9;
  45. wrapper = mount(
  46. <ProcessingIssueHint issue={issue} orgId={orgId} projectId={projectId} />
  47. );
  48. });
  49. it('does not display a button', function() {
  50. const button = wrapper.find('Link');
  51. expect(button.length).toBe(0);
  52. });
  53. it('displays an icon', function() {
  54. const icon = wrapper.find('[className*="icon-processing"]');
  55. expect(icon.length).toBe(1);
  56. });
  57. it('displays text', function() {
  58. const text = wrapper.find('Container').text();
  59. expect(text).toEqual(expect.stringContaining('Reprocessing'));
  60. });
  61. });
  62. describe('resolvableIssues state', function() {
  63. beforeEach(() => {
  64. issue.resolveableIssues = 9;
  65. wrapper = mount(
  66. <ProcessingIssueHint issue={issue} orgId={orgId} projectId={projectId} />
  67. );
  68. });
  69. it('displays a button', function() {
  70. const button = wrapper.find('Link');
  71. expect(button.length).toBe(1);
  72. expect(button.props().to).toEqual(
  73. `/settings/${orgId}/projects/${projectId}/processing-issues/`
  74. );
  75. });
  76. it('displays an icon', function() {
  77. const icon = wrapper.find('[className*="icon-processing"]');
  78. expect(icon.length).toBe(1);
  79. });
  80. it('displays text', function() {
  81. const text = wrapper.find('Container').text();
  82. expect(text).toEqual(expect.stringContaining('pending reprocessing'));
  83. });
  84. });
  85. describe('showProject state', function() {
  86. beforeEach(() => {
  87. issue.numIssues = 9;
  88. wrapper = mount(
  89. <ProcessingIssueHint
  90. showProject
  91. issue={issue}
  92. orgId={orgId}
  93. projectId={projectId}
  94. />
  95. );
  96. });
  97. it('displays the project slug', function() {
  98. const text = wrapper.find('Container').text();
  99. expect(text).toEqual(expect.stringContaining(projectId));
  100. });
  101. });
  102. });