sentryAppDetailsModal.spec.jsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import React from 'react';
  2. import {mount} from 'enzyme';
  3. import SentryAppDetailsModal from 'app/components/modals/sentryAppDetailsModal';
  4. describe('SentryAppDetailsModal', function() {
  5. let wrapper;
  6. let org;
  7. let sentryApp;
  8. let onInstall;
  9. let isInstalled;
  10. let closeModal;
  11. function render() {
  12. return mount(
  13. <SentryAppDetailsModal
  14. sentryApp={sentryApp}
  15. organization={org}
  16. onInstall={onInstall}
  17. isInstalled={isInstalled}
  18. closeModal={closeModal}
  19. />,
  20. TestStubs.routerContext()
  21. );
  22. }
  23. beforeEach(() => {
  24. org = TestStubs.Organization();
  25. sentryApp = TestStubs.SentryApp();
  26. onInstall = jest.fn();
  27. isInstalled = false;
  28. closeModal = jest.fn();
  29. wrapper = render();
  30. });
  31. it('renders', () => {
  32. expect(wrapper.find('Name').text()).toBe(sentryApp.name);
  33. });
  34. it('displays the Integrations description', () => {
  35. expect(wrapper.find('Description').text()).toBe(sentryApp.overview);
  36. });
  37. it('closes when Cancel is clicked', () => {
  38. wrapper.find({onClick: closeModal}).simulate('click');
  39. expect(closeModal).toHaveBeenCalled();
  40. });
  41. it('installs the Integration when Install is clicked', () => {
  42. wrapper.find({onClick: onInstall}).simulate('click');
  43. expect(onInstall).toHaveBeenCalled();
  44. });
  45. describe('when the User does not have permission to install Integrations', () => {
  46. beforeEach(() => {
  47. org = {...org, access: []};
  48. wrapper = render();
  49. });
  50. it('does not display the Install button', () => {
  51. expect(wrapper.find({onClick: onInstall}).length).toBe(0);
  52. });
  53. });
  54. describe('when the Integration is installed', () => {
  55. beforeEach(() => {
  56. isInstalled = true;
  57. wrapper = render();
  58. });
  59. it('disabled the Install button', () => {
  60. expect(wrapper.find({onClick: onInstall}).prop('disabled')).toBe(true);
  61. });
  62. });
  63. });