processingIssueList.spec.jsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import React from 'react';
  2. import {shallow} from 'enzyme';
  3. import ProcessingIssueList from 'app/components/stream/processingIssueList';
  4. describe('ProcessingIssueList', function() {
  5. let wrapper, projects, organization, fetchIssueRequest;
  6. beforeEach(function() {
  7. fetchIssueRequest = MockApiClient.addMockResponse({
  8. url: '/organizations/org-slug/processingissues/',
  9. method: 'GET',
  10. body: [
  11. {
  12. project: 'test-project',
  13. numIssues: 1,
  14. hasIssues: true,
  15. lastSeen: '2019-01-16T15:39:11.081Z',
  16. },
  17. {
  18. project: 'other-project',
  19. numIssues: 1,
  20. hasIssues: true,
  21. lastSeen: '2019-01-16T15:39:11.081Z',
  22. },
  23. ],
  24. });
  25. organization = TestStubs.Organization();
  26. projects = [1, 2];
  27. });
  28. describe('componentDidMount', function() {
  29. let instance;
  30. beforeEach(async function() {
  31. wrapper = shallow(
  32. <ProcessingIssueList organization={organization} projects={projects} />
  33. );
  34. instance = wrapper.instance();
  35. await instance.componentDidMount();
  36. });
  37. it('fetches issues', function() {
  38. expect(instance.state.issues).toBeTruthy();
  39. expect(fetchIssueRequest).toHaveBeenCalled();
  40. });
  41. });
  42. describe('render', function() {
  43. beforeEach(async function() {
  44. wrapper = shallow(
  45. <ProcessingIssueList
  46. organization={organization}
  47. projects={projects}
  48. showProject={true}
  49. />
  50. );
  51. await wrapper.instance().componentDidMount();
  52. await wrapper.update();
  53. });
  54. it('renders multiple issues', function() {
  55. expect(wrapper.find('ProcessingIssueHint')).toHaveLength(2);
  56. });
  57. it('forwards the showProject prop', function() {
  58. const hint = wrapper.find('ProcessingIssueHint').first();
  59. expect(hint.props().showProject).toBeTruthy();
  60. });
  61. });
  62. });