groupMergedView.spec.jsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import {shallow} from 'enzyme';
  4. import GroupMergedView from 'app/views/groupDetails/shared/groupMerged';
  5. import {Client} from 'app/api';
  6. import events from 'app-test/mocks/events';
  7. jest.mock('app/api');
  8. jest.mock('app/mixins/projectState', () => {
  9. return {
  10. getFeatures: () => new Set([]),
  11. };
  12. });
  13. const mockData = {
  14. merged: [
  15. {
  16. latestEvent: events[0],
  17. state: 'unlocked',
  18. id: '2c4887696f708c476a81ce4e834c4b02',
  19. },
  20. {
  21. latestEvent: events[1],
  22. state: 'unlocked',
  23. id: 'e05da55328a860b21f62e371f0a7507d',
  24. },
  25. ],
  26. };
  27. describe('Issues -> Merged View', function() {
  28. let context = {
  29. group: {
  30. id: 'id',
  31. tags: [],
  32. },
  33. };
  34. beforeAll(function() {
  35. Client.addMockResponse({
  36. url: '/issues/groupId/hashes/?limit=50&query=',
  37. body: mockData.merged,
  38. });
  39. });
  40. it('renders initially with loading component', function() {
  41. let wrapper = shallow(
  42. <GroupMergedView
  43. params={{orgId: 'orgId', projectId: 'projectId', groupId: 'groupId'}}
  44. location={{query: {}}}
  45. />,
  46. TestStubs.routerContext()
  47. );
  48. expect(wrapper.find('LoadingIndicator')).toHaveLength(1);
  49. });
  50. it('renders with mocked data', async function() {
  51. let wrapper = shallow(
  52. <GroupMergedView
  53. params={{orgId: 'orgId', projectId: 'projectId', groupId: 'groupId'}}
  54. location={{query: {}}}
  55. />,
  56. {
  57. ...TestStubs.routerContext([
  58. {
  59. group: context,
  60. },
  61. {
  62. group: PropTypes.object,
  63. },
  64. ]),
  65. disableLifecycleMethods: false,
  66. }
  67. );
  68. await tick();
  69. await tick();
  70. wrapper.update();
  71. expect(wrapper.find('LoadingIndicator')).toHaveLength(0);
  72. expect(wrapper).toMatchSnapshot();
  73. });
  74. });