organizationAccessRequests.spec.jsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import React from 'react';
  2. import {shallow, mount} from 'enzyme';
  3. import OrganizationAccessRequests from 'app/views/settings/organization/members/organizationAccessRequests';
  4. import {ThemeProvider} from 'emotion-theming';
  5. describe('OrganizationAccessRequests', function() {
  6. beforeEach(function() {});
  7. it('renders empty', function() {
  8. let wrapper = shallow(
  9. <OrganizationAccessRequests
  10. params={{apiKey: 1, orgId: 'org-slug'}}
  11. onApprove={() => {}}
  12. onDeny={() => {}}
  13. />
  14. );
  15. expect(wrapper).toMatchSnapshot();
  16. });
  17. it('renders list', function() {
  18. let wrapper = shallow(
  19. <OrganizationAccessRequests
  20. params={{apiKey: 1, orgId: 'org-slug'}}
  21. accessRequestBusy={new Map()}
  22. requestList={[
  23. {
  24. id: 'id',
  25. member: {
  26. id: 'memberid',
  27. email: '',
  28. name: '',
  29. roleName: '',
  30. user: {
  31. id: '',
  32. name: 'sentry@test.com',
  33. },
  34. },
  35. team: TestStubs.Team(),
  36. },
  37. ]}
  38. onApprove={() => {}}
  39. onDeny={() => {}}
  40. />
  41. );
  42. expect(wrapper).toMatchSnapshot();
  43. });
  44. it('can approve', function() {
  45. let mock = jest.fn();
  46. let wrapper = mount(
  47. <ThemeProvider theme={{}}>
  48. <OrganizationAccessRequests
  49. params={{apiKey: 1, orgId: 'org-slug'}}
  50. accessRequestBusy={new Map()}
  51. requestList={[
  52. {
  53. id: 'id',
  54. member: {
  55. id: 'memberid',
  56. email: '',
  57. name: '',
  58. roleName: '',
  59. user: {
  60. id: '',
  61. name: 'sentry@test.com',
  62. },
  63. },
  64. team: TestStubs.Team(),
  65. },
  66. ]}
  67. onApprove={mock}
  68. onDeny={() => {}}
  69. />
  70. </ThemeProvider>
  71. );
  72. wrapper
  73. .find('Button')
  74. .first()
  75. .simulate('click');
  76. expect(mock).toHaveBeenCalled();
  77. });
  78. it('can deny', function() {
  79. let mock = jest.fn();
  80. let wrapper = mount(
  81. <ThemeProvider theme={{}}>
  82. <OrganizationAccessRequests
  83. params={{apiKey: 1, orgId: 'org-slug'}}
  84. accessRequestBusy={new Map()}
  85. requestList={[
  86. {
  87. id: 'id',
  88. member: {
  89. id: 'memberid',
  90. email: '',
  91. name: '',
  92. roleName: '',
  93. user: {
  94. id: '',
  95. name: 'sentry@test.com',
  96. },
  97. },
  98. team: TestStubs.Team(),
  99. },
  100. ]}
  101. onApprove={() => {}}
  102. onDeny={mock}
  103. />
  104. </ThemeProvider>
  105. );
  106. wrapper
  107. .find('Button')
  108. .last()
  109. .simulate('click');
  110. expect(mock).toHaveBeenCalled();
  111. });
  112. });