mirror of
https://github.com/ansible/awx.git
synced 2026-03-01 00:38:45 -03:30
remove 2nd batch of unecessary unmount calls
This commit is contained in:
@@ -4,9 +4,7 @@ import CredentialPluginTestAlert from './CredentialPluginTestAlert';
|
|||||||
|
|
||||||
describe('<CredentialPluginTestAlert />', () => {
|
describe('<CredentialPluginTestAlert />', () => {
|
||||||
let wrapper;
|
let wrapper;
|
||||||
afterEach(() => {
|
|
||||||
wrapper.unmount();
|
|
||||||
});
|
|
||||||
test('renders expected content when test is successful', () => {
|
test('renders expected content when test is successful', () => {
|
||||||
wrapper = mountWithContexts(
|
wrapper = mountWithContexts(
|
||||||
<CredentialPluginTestAlert
|
<CredentialPluginTestAlert
|
||||||
@@ -20,6 +18,7 @@ describe('<CredentialPluginTestAlert />', () => {
|
|||||||
'Test passed'
|
'Test passed'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('renders expected content when test fails with the expected return string formatting', () => {
|
test('renders expected content when test fails with the expected return string formatting', () => {
|
||||||
wrapper = mountWithContexts(
|
wrapper = mountWithContexts(
|
||||||
<CredentialPluginTestAlert
|
<CredentialPluginTestAlert
|
||||||
@@ -41,6 +40,7 @@ describe('<CredentialPluginTestAlert />', () => {
|
|||||||
'HTTP 404: not found'
|
'HTTP 404: not found'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('renders expected content when test fails without the expected return string formatting', () => {
|
test('renders expected content when test fails without the expected return string formatting', () => {
|
||||||
wrapper = mountWithContexts(
|
wrapper = mountWithContexts(
|
||||||
<CredentialPluginTestAlert
|
<CredentialPluginTestAlert
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ const credential = {
|
|||||||
|
|
||||||
describe('<ExternalTestModal />', () => {
|
describe('<ExternalTestModal />', () => {
|
||||||
let wrapper;
|
let wrapper;
|
||||||
afterEach(() => wrapper.unmount());
|
|
||||||
test('should display metadata fields correctly', async () => {
|
test('should display metadata fields correctly', async () => {
|
||||||
wrapper = mountWithContexts(
|
wrapper = mountWithContexts(
|
||||||
<ExternalTestModal
|
<ExternalTestModal
|
||||||
@@ -46,6 +46,7 @@ describe('<ExternalTestModal />', () => {
|
|||||||
expect(wrapper.find('input#credential-secret_key').length).toBe(1);
|
expect(wrapper.find('input#credential-secret_key').length).toBe(1);
|
||||||
expect(wrapper.find('input#credential-secret_version').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 () => {
|
test('should make the test request correctly when testing an existing credential', async () => {
|
||||||
wrapper = mountWithContexts(
|
wrapper = mountWithContexts(
|
||||||
<ExternalTestModal
|
<ExternalTestModal
|
||||||
@@ -85,6 +86,7 @@ describe('<ExternalTestModal />', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should make the test request correctly when testing a new credential', async () => {
|
test('should make the test request correctly when testing a new credential', async () => {
|
||||||
wrapper = mountWithContexts(
|
wrapper = mountWithContexts(
|
||||||
<ExternalTestModal
|
<ExternalTestModal
|
||||||
@@ -123,6 +125,7 @@ describe('<ExternalTestModal />', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should display the alert after a successful test', async () => {
|
test('should display the alert after a successful test', async () => {
|
||||||
CredentialTypesAPI.test.mockResolvedValue({});
|
CredentialTypesAPI.test.mockResolvedValue({});
|
||||||
wrapper = mountWithContexts(
|
wrapper = mountWithContexts(
|
||||||
@@ -148,6 +151,7 @@ describe('<ExternalTestModal />', () => {
|
|||||||
expect(wrapper.find('Alert').length).toBe(1);
|
expect(wrapper.find('Alert').length).toBe(1);
|
||||||
expect(wrapper.find('Alert').props().variant).toBe('success');
|
expect(wrapper.find('Alert').props().variant).toBe('success');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should display the alert after a failed test', async () => {
|
test('should display the alert after a failed test', async () => {
|
||||||
CredentialTypesAPI.test.mockRejectedValue({
|
CredentialTypesAPI.test.mockRejectedValue({
|
||||||
inputs: `HTTP 404
|
inputs: `HTTP 404
|
||||||
|
|||||||
@@ -4,10 +4,6 @@ import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
|||||||
|
|
||||||
import CredentialTypes from './CredentialTypes';
|
import CredentialTypes from './CredentialTypes';
|
||||||
|
|
||||||
jest.mock('react-router-dom', () => ({
|
|
||||||
...jest.requireActual('react-router-dom'),
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('<CredentialTypes/>', () => {
|
describe('<CredentialTypes/>', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
let pageSections;
|
let pageSections;
|
||||||
@@ -17,10 +13,6 @@ describe('<CredentialTypes/>', () => {
|
|||||||
pageSections = pageWrapper.find('PageSection');
|
pageSections = pageWrapper.find('PageSection');
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
pageWrapper.unmount();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('initially renders without crashing', () => {
|
test('initially renders without crashing', () => {
|
||||||
expect(pageWrapper.length).toBe(1);
|
expect(pageWrapper.length).toBe(1);
|
||||||
expect(pageSections.length).toBe(1);
|
expect(pageSections.length).toBe(1);
|
||||||
|
|||||||
@@ -7,9 +7,6 @@ import { DashboardAPI } from '../../api';
|
|||||||
import Dashboard from './Dashboard';
|
import Dashboard from './Dashboard';
|
||||||
|
|
||||||
jest.mock('../../api');
|
jest.mock('../../api');
|
||||||
jest.mock('react-router-dom', () => ({
|
|
||||||
...jest.requireActual('react-router-dom'),
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('<Dashboard />', () => {
|
describe('<Dashboard />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
@@ -24,10 +21,6 @@ describe('<Dashboard />', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
pageWrapper.unmount();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('initially renders without crashing', () => {
|
test('initially renders without crashing', () => {
|
||||||
expect(pageWrapper.length).toBe(1);
|
expect(pageWrapper.length).toBe(1);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,9 +7,6 @@ import { DashboardAPI } from '../../api';
|
|||||||
import DashboardGraph from './DashboardGraph';
|
import DashboardGraph from './DashboardGraph';
|
||||||
|
|
||||||
jest.mock('../../api');
|
jest.mock('../../api');
|
||||||
jest.mock('react-router-dom', () => ({
|
|
||||||
...jest.requireActual('react-router-dom'),
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('<DashboardGraph/>', () => {
|
describe('<DashboardGraph/>', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
@@ -24,9 +21,6 @@ describe('<DashboardGraph/>', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
pageWrapper.unmount();
|
|
||||||
});
|
|
||||||
test('renders month-based/all job type chart by default', () => {
|
test('renders month-based/all job type chart by default', () => {
|
||||||
expect(graphRequest).toHaveBeenCalledWith({
|
expect(graphRequest).toHaveBeenCalledWith({
|
||||||
job_type: 'all',
|
job_type: 'all',
|
||||||
|
|||||||
@@ -7,10 +7,6 @@ import Count from './Count';
|
|||||||
describe('<Count />', () => {
|
describe('<Count />', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
pageWrapper.unmount();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('initially renders without crashing', () => {
|
test('initially renders without crashing', () => {
|
||||||
pageWrapper = mountWithContexts(<Count link="foo" />);
|
pageWrapper = mountWithContexts(<Count link="foo" />);
|
||||||
expect(pageWrapper.length).toBe(1);
|
expect(pageWrapper.length).toBe(1);
|
||||||
|
|||||||
@@ -90,7 +90,6 @@ describe('<ExecutionEnvironmentAdd/>', () => {
|
|||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
wrapper.unmount();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('handleSubmit should call the api and redirect to details page', async () => {
|
test('handleSubmit should call the api and redirect to details page', async () => {
|
||||||
|
|||||||
@@ -82,7 +82,6 @@ describe('<ExecutionEnvironmentEdit/>', () => {
|
|||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
wrapper.unmount();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('handleSubmit should call the api and redirect to details page', async () => {
|
test('handleSubmit should call the api and redirect to details page', async () => {
|
||||||
|
|||||||
@@ -13,10 +13,6 @@ describe('<ExecutionEnvironments/>', () => {
|
|||||||
pageSections = pageWrapper.find('PageSection');
|
pageSections = pageWrapper.find('PageSection');
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
pageWrapper.unmount();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('initially renders without crashing', () => {
|
test('initially renders without crashing', () => {
|
||||||
expect(pageWrapper.length).toBe(1);
|
expect(pageWrapper.length).toBe(1);
|
||||||
expect(pageSections.length).toBe(1);
|
expect(pageSections.length).toBe(1);
|
||||||
|
|||||||
@@ -37,10 +37,6 @@ describe('<Host />', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
wrapper.unmount();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should render expected tabs', async () => {
|
test('should render expected tabs', async () => {
|
||||||
const expectedTabs = ['Details', 'Facts', 'Groups', 'Completed Jobs'];
|
const expectedTabs = ['Details', 'Facts', 'Groups', 'Completed Jobs'];
|
||||||
wrapper.find('RoutedTabs li').forEach((tab, index) => {
|
wrapper.find('RoutedTabs li').forEach((tab, index) => {
|
||||||
|
|||||||
@@ -38,10 +38,6 @@ describe('<HostsListItem />', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
wrapper.unmount();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('edit button shown to users with edit capabilities', () => {
|
test('edit button shown to users with edit capabilities', () => {
|
||||||
expect(wrapper.find('PencilAltIcon').exists()).toBeTruthy();
|
expect(wrapper.find('PencilAltIcon').exists()).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,41 +1,28 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { createMemoryHistory } from 'history';
|
import { createMemoryHistory } from 'history';
|
||||||
|
import { shallow } from 'enzyme';
|
||||||
|
import { act } from 'react-dom/test-utils';
|
||||||
|
|
||||||
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
||||||
|
|
||||||
import Hosts from './Hosts';
|
import Hosts from './Hosts';
|
||||||
|
|
||||||
jest.mock('react-router-dom', () => ({
|
jest.mock('../../api');
|
||||||
...jest.requireActual('react-router-dom'),
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('<Hosts />', () => {
|
describe('<Hosts />', () => {
|
||||||
test('initially renders successfully', () => {
|
|
||||||
mountWithContexts(<Hosts />);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should display a breadcrumb heading', () => {
|
test('should display a breadcrumb heading', () => {
|
||||||
const history = createMemoryHistory({
|
const wrapper = shallow(<Hosts />);
|
||||||
initialEntries: ['/hosts'],
|
|
||||||
});
|
|
||||||
const match = { path: '/hosts', url: '/hosts', isExact: true };
|
|
||||||
|
|
||||||
const wrapper = mountWithContexts(<Hosts />, {
|
const header = wrapper.find('ScreenHeader');
|
||||||
context: {
|
expect(header.prop('streamType')).toEqual('host');
|
||||||
router: {
|
expect(header.prop('breadcrumbConfig')).toEqual({
|
||||||
history,
|
'/hosts': 'Hosts',
|
||||||
route: {
|
'/hosts/add': 'Create New Host',
|
||||||
location: history.location,
|
|
||||||
match,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
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({
|
const history = createMemoryHistory({
|
||||||
initialEntries: ['/hosts/1'],
|
initialEntries: ['/hosts/1'],
|
||||||
});
|
});
|
||||||
@@ -46,11 +33,12 @@ describe('<Hosts />', () => {
|
|||||||
isExact: true,
|
isExact: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const wrapper = mountWithContexts(<Hosts />, {
|
await act(async () => {
|
||||||
context: { router: { history, route: { match } } },
|
wrapper = await mountWithContexts(<Hosts />, {
|
||||||
|
context: { router: { history, route: { match } } },
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(wrapper.find('Host').length).toBe(1);
|
expect(wrapper.find('Host').length).toBe(1);
|
||||||
wrapper.unmount();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ describe('<InstanceGroupEdit>', () => {
|
|||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
wrapper.unmount();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('controlplane instance group name can not be updated', async () => {
|
test('controlplane instance group name can not be updated', async () => {
|
||||||
|
|||||||
@@ -4,10 +4,6 @@ import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
|||||||
|
|
||||||
import InstanceGroups from './InstanceGroups';
|
import InstanceGroups from './InstanceGroups';
|
||||||
|
|
||||||
jest.mock('react-router-dom', () => ({
|
|
||||||
...jest.requireActual('react-router-dom'),
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('<InstanceGroups/>', () => {
|
describe('<InstanceGroups/>', () => {
|
||||||
let pageWrapper;
|
let pageWrapper;
|
||||||
let pageSections;
|
let pageSections;
|
||||||
@@ -17,10 +13,6 @@ describe('<InstanceGroups/>', () => {
|
|||||||
pageSections = pageWrapper.find('PageSection');
|
pageSections = pageWrapper.find('PageSection');
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
pageWrapper.unmount();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('initially renders without crashing', () => {
|
test('initially renders without crashing', () => {
|
||||||
expect(pageWrapper.length).toBe(1);
|
expect(pageWrapper.length).toBe(1);
|
||||||
expect(pageSections.length).toBe(1);
|
expect(pageSections.length).toBe(1);
|
||||||
|
|||||||
@@ -134,7 +134,6 @@ describe('<InstanceList/>', () => {
|
|||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
wrapper.unmount();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should have data fetched', () => {
|
test('should have data fetched', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user