organizationApiKeysList.spec.jsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import React from 'react';
  2. import {mount} from 'enzyme';
  3. import OrganizationApiKeysList from 'app/views/settings/organizationApiKeys/organizationApiKeysList';
  4. jest.unmock('app/utils/recreateRoute');
  5. const routes = [
  6. {path: '/'},
  7. {path: '/:orgId/'},
  8. {path: '/organizations/:orgId/'},
  9. {path: 'api-keys/', name: 'API Key'},
  10. ];
  11. describe('OrganizationApiKeysList', function() {
  12. beforeEach(function() {});
  13. it('renders', function() {
  14. let wrapper = mount(
  15. <OrganizationApiKeysList
  16. params={{orgId: 'org-slug'}}
  17. routes={routes}
  18. keys={[TestStubs.ApiKey()]}
  19. />,
  20. TestStubs.routerContext()
  21. );
  22. expect(wrapper).toMatchSnapshot();
  23. });
  24. it('opens a modal when trying to delete a key', function() {
  25. let wrapper = mount(
  26. <OrganizationApiKeysList
  27. params={{orgId: 'org-slug'}}
  28. routes={routes}
  29. keys={[TestStubs.ApiKey()]}
  30. />,
  31. TestStubs.routerContext()
  32. );
  33. wrapper.update();
  34. // Click remove button
  35. wrapper.find('.icon-trash').simulate('click');
  36. wrapper.update();
  37. // expect a modal
  38. let modal = wrapper.find('Modal');
  39. expect(modal.first().prop('show')).toBe(true);
  40. });
  41. });