remove 2nd batch of unecessary unmount calls

This commit is contained in:
Keith J. Grant 2021-07-08 17:06:15 -07:00
parent 86fcfdf69a
commit bf7663a0a1
15 changed files with 23 additions and 80 deletions

View File

@ -4,9 +4,7 @@ import CredentialPluginTestAlert from './CredentialPluginTestAlert';
describe('<CredentialPluginTestAlert />', () => {
let wrapper;
afterEach(() => {
wrapper.unmount();
});
test('renders expected content when test is successful', () => {
wrapper = mountWithContexts(
<CredentialPluginTestAlert
@ -20,6 +18,7 @@ describe('<CredentialPluginTestAlert />', () => {
'Test passed'
);
});
test('renders expected content when test fails with the expected return string formatting', () => {
wrapper = mountWithContexts(
<CredentialPluginTestAlert
@ -41,6 +40,7 @@ describe('<CredentialPluginTestAlert />', () => {
'HTTP 404: not found'
);
});
test('renders expected content when test fails without the expected return string formatting', () => {
wrapper = mountWithContexts(
<CredentialPluginTestAlert

View File

@ -30,7 +30,7 @@ const credential = {
describe('<ExternalTestModal />', () => {
let wrapper;
afterEach(() => wrapper.unmount());
test('should display metadata fields correctly', async () => {
wrapper = mountWithContexts(
<ExternalTestModal
@ -46,6 +46,7 @@ describe('<ExternalTestModal />', () => {
expect(wrapper.find('input#credential-secret_key').length).toBe(1);
expect(wrapper.find('input#credential-secret_version').length).toBe(1);
});
test('should make the test request correctly when testing an existing credential', async () => {
wrapper = mountWithContexts(
<ExternalTestModal
@ -85,6 +86,7 @@ describe('<ExternalTestModal />', () => {
},
});
});
test('should make the test request correctly when testing a new credential', async () => {
wrapper = mountWithContexts(
<ExternalTestModal
@ -123,6 +125,7 @@ describe('<ExternalTestModal />', () => {
},
});
});
test('should display the alert after a successful test', async () => {
CredentialTypesAPI.test.mockResolvedValue({});
wrapper = mountWithContexts(
@ -148,6 +151,7 @@ describe('<ExternalTestModal />', () => {
expect(wrapper.find('Alert').length).toBe(1);
expect(wrapper.find('Alert').props().variant).toBe('success');
});
test('should display the alert after a failed test', async () => {
CredentialTypesAPI.test.mockRejectedValue({
inputs: `HTTP 404

View File

@ -4,10 +4,6 @@ import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
import CredentialTypes from './CredentialTypes';
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
}));
describe('<CredentialTypes/>', () => {
let pageWrapper;
let pageSections;
@ -17,10 +13,6 @@ describe('<CredentialTypes/>', () => {
pageSections = pageWrapper.find('PageSection');
});
afterEach(() => {
pageWrapper.unmount();
});
test('initially renders without crashing', () => {
expect(pageWrapper.length).toBe(1);
expect(pageSections.length).toBe(1);

View File

@ -7,9 +7,6 @@ import { DashboardAPI } from '../../api';
import Dashboard from './Dashboard';
jest.mock('../../api');
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
}));
describe('<Dashboard />', () => {
let pageWrapper;
@ -24,10 +21,6 @@ describe('<Dashboard />', () => {
});
});
afterEach(() => {
pageWrapper.unmount();
});
test('initially renders without crashing', () => {
expect(pageWrapper.length).toBe(1);
});

View File

@ -7,9 +7,6 @@ import { DashboardAPI } from '../../api';
import DashboardGraph from './DashboardGraph';
jest.mock('../../api');
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
}));
describe('<DashboardGraph/>', () => {
let pageWrapper;
@ -24,9 +21,6 @@ describe('<DashboardGraph/>', () => {
});
});
afterEach(() => {
pageWrapper.unmount();
});
test('renders month-based/all job type chart by default', () => {
expect(graphRequest).toHaveBeenCalledWith({
job_type: 'all',

View File

@ -7,10 +7,6 @@ import Count from './Count';
describe('<Count />', () => {
let pageWrapper;
afterEach(() => {
pageWrapper.unmount();
});
test('initially renders without crashing', () => {
pageWrapper = mountWithContexts(<Count link="foo" />);
expect(pageWrapper.length).toBe(1);

View File

@ -90,7 +90,6 @@ describe('<ExecutionEnvironmentAdd/>', () => {
afterEach(() => {
jest.clearAllMocks();
wrapper.unmount();
});
test('handleSubmit should call the api and redirect to details page', async () => {

View File

@ -82,7 +82,6 @@ describe('<ExecutionEnvironmentEdit/>', () => {
afterAll(() => {
jest.clearAllMocks();
wrapper.unmount();
});
test('handleSubmit should call the api and redirect to details page', async () => {

View File

@ -13,10 +13,6 @@ describe('<ExecutionEnvironments/>', () => {
pageSections = pageWrapper.find('PageSection');
});
afterEach(() => {
pageWrapper.unmount();
});
test('initially renders without crashing', () => {
expect(pageWrapper.length).toBe(1);
expect(pageSections.length).toBe(1);

View File

@ -37,10 +37,6 @@ describe('<Host />', () => {
});
});
afterEach(() => {
wrapper.unmount();
});
test('should render expected tabs', async () => {
const expectedTabs = ['Details', 'Facts', 'Groups', 'Completed Jobs'];
wrapper.find('RoutedTabs li').forEach((tab, index) => {

View File

@ -38,10 +38,6 @@ describe('<HostsListItem />', () => {
);
});
afterEach(() => {
wrapper.unmount();
});
test('edit button shown to users with edit capabilities', () => {
expect(wrapper.find('PencilAltIcon').exists()).toBeTruthy();
});

View File

@ -1,41 +1,28 @@
import React from 'react';
import { createMemoryHistory } from 'history';
import { shallow } from 'enzyme';
import { act } from 'react-dom/test-utils';
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
import Hosts from './Hosts';
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
}));
jest.mock('../../api');
describe('<Hosts />', () => {
test('initially renders successfully', () => {
mountWithContexts(<Hosts />);
});
test('should display a breadcrumb heading', () => {
const history = createMemoryHistory({
initialEntries: ['/hosts'],
});
const match = { path: '/hosts', url: '/hosts', isExact: true };
const wrapper = shallow(<Hosts />);
const wrapper = mountWithContexts(<Hosts />, {
context: {
router: {
history,
route: {
location: history.location,
match,
},
},
},
const header = wrapper.find('ScreenHeader');
expect(header.prop('streamType')).toEqual('host');
expect(header.prop('breadcrumbConfig')).toEqual({
'/hosts': 'Hosts',
'/hosts/add': 'Create New Host',
});
expect(wrapper.find('Title').length).toBe(1);
wrapper.unmount();
});
test('should render Host component', () => {
test('should render Host component', async () => {
let wrapper;
const history = createMemoryHistory({
initialEntries: ['/hosts/1'],
});
@ -46,11 +33,12 @@ describe('<Hosts />', () => {
isExact: true,
};
const wrapper = mountWithContexts(<Hosts />, {
context: { router: { history, route: { match } } },
await act(async () => {
wrapper = await mountWithContexts(<Hosts />, {
context: { router: { history, route: { match } } },
});
});
expect(wrapper.find('Host').length).toBe(1);
wrapper.unmount();
});
});

View File

@ -68,7 +68,6 @@ describe('<InstanceGroupEdit>', () => {
afterAll(() => {
jest.clearAllMocks();
wrapper.unmount();
});
test('controlplane instance group name can not be updated', async () => {

View File

@ -4,10 +4,6 @@ import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
import InstanceGroups from './InstanceGroups';
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
}));
describe('<InstanceGroups/>', () => {
let pageWrapper;
let pageSections;
@ -17,10 +13,6 @@ describe('<InstanceGroups/>', () => {
pageSections = pageWrapper.find('PageSection');
});
afterEach(() => {
pageWrapper.unmount();
});
test('initially renders without crashing', () => {
expect(pageWrapper.length).toBe(1);
expect(pageSections.length).toBe(1);

View File

@ -134,7 +134,6 @@ describe('<InstanceList/>', () => {
afterEach(() => {
jest.clearAllMocks();
wrapper.unmount();
});
test('should have data fetched', () => {