organizationApiKeysList.spec.jsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import PropTypes from 'prop-types';
  2. import React from 'react';
  3. import {mount} from 'enzyme';
  4. import OrganizationApiKeysList from 'app/views/settings/organization/apiKeys/organizationApiKeysList';
  5. const childContextTypes = {
  6. organization: PropTypes.object,
  7. router: PropTypes.object,
  8. location: PropTypes.object,
  9. };
  10. const routes = [
  11. {path: '/'},
  12. {path: '/:orgId/'},
  13. {path: '/organizations/:orgId/'},
  14. {path: 'api-keys/', name: 'API Key'},
  15. ];
  16. describe('OrganizationApiKeysList', function() {
  17. beforeEach(function() {});
  18. it('renders', function() {
  19. let wrapper = mount(
  20. <OrganizationApiKeysList
  21. params={{orgId: 'org-slug'}}
  22. routes={routes}
  23. keys={[TestStubs.ApiKey()]}
  24. />
  25. );
  26. expect(wrapper).toMatchSnapshot();
  27. });
  28. it('opens a modal when trying to delete a key', function() {
  29. let wrapper = mount(
  30. <OrganizationApiKeysList
  31. params={{orgId: 'org-slug'}}
  32. routes={routes}
  33. keys={[TestStubs.ApiKey()]}
  34. />,
  35. {
  36. context: {
  37. router: TestStubs.router(),
  38. organization: TestStubs.Organization(),
  39. location: TestStubs.location(),
  40. },
  41. childContextTypes,
  42. }
  43. );
  44. wrapper.update();
  45. // Click remove button
  46. wrapper.find('.icon-trash').simulate('click');
  47. wrapper.update();
  48. // expect a modal
  49. let modal = wrapper.find('Modal');
  50. expect(modal.first().prop('show')).toBe(true);
  51. });
  52. });