123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import PropTypes from 'prop-types';
- import React from 'react';
- import {mount} from 'enzyme';
- import OrganizationApiKeysList from 'app/views/settings/organization/apiKeys/organizationApiKeysList';
- const childContextTypes = {
- organization: PropTypes.object,
- router: PropTypes.object,
- location: PropTypes.object,
- };
- const routes = [
- {path: '/'},
- {path: '/:orgId/'},
- {path: '/organizations/:orgId/'},
- {path: 'api-keys/', name: 'API Key'},
- ];
- describe('OrganizationApiKeysList', function() {
- beforeEach(function() {});
- it('renders', function() {
- let wrapper = mount(
- <OrganizationApiKeysList
- params={{orgId: 'org-slug'}}
- routes={routes}
- keys={[TestStubs.ApiKey()]}
- />
- );
- expect(wrapper).toMatchSnapshot();
- });
- it('opens a modal when trying to delete a key', function() {
- let wrapper = mount(
- <OrganizationApiKeysList
- params={{orgId: 'org-slug'}}
- routes={routes}
- keys={[TestStubs.ApiKey()]}
- />,
- {
- context: {
- router: TestStubs.router(),
- organization: TestStubs.Organization(),
- location: TestStubs.location(),
- },
- childContextTypes,
- }
- );
- wrapper.update();
- // Click remove button
- wrapper.find('.icon-trash').simulate('click');
- wrapper.update();
- // expect a modal
- let modal = wrapper.find('Modal');
- expect(modal.first().prop('show')).toBe(true);
- });
- });
|