remove 3rd batch of unmount calls

This commit is contained in:
Keith J. Grant 2021-07-09 09:08:32 -07:00
parent bf7663a0a1
commit 81c16f4fa7
69 changed files with 51 additions and 211 deletions

View File

@ -145,7 +145,6 @@ describe('<ExecutionEnvironmentForm/>', () => {
afterEach(() => {
jest.clearAllMocks();
wrapper.unmount();
});
test('Initially renders successfully', () => {

View File

@ -108,7 +108,6 @@ describe('<HostGroupsList />', () => {
afterEach(() => {
jest.clearAllMocks();
wrapper.unmount();
});
test('initially renders successfully', () => {

View File

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

View File

@ -113,7 +113,6 @@ describe('<ContainerGroupEdit/>', () => {
afterEach(() => {
jest.clearAllMocks();
wrapper.unmount();
});
test('initially renders successfully', async () => {

View File

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

View File

@ -91,7 +91,6 @@ describe('<ContainerGroupForm/>', () => {
afterEach(() => {
jest.clearAllMocks();
wrapper.unmount();
});
test('Initially renders successfully', () => {

View File

@ -60,7 +60,6 @@ describe('<InstanceGroupForm/>', () => {
afterEach(() => {
jest.clearAllMocks();
wrapper.unmount();
});
test('Initially renders successfully', () => {

View File

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

View File

@ -43,7 +43,6 @@ describe('<InventoryGroupHostList />', () => {
afterEach(() => {
jest.clearAllMocks();
wrapper.unmount();
});
test('initially renders successfully ', () => {

View File

@ -26,10 +26,6 @@ describe('<InventoryGroupHostListItem />', () => {
);
});
afterEach(() => {
wrapper.unmount();
});
test('should display expected row item content', () => {
expect(wrapper.find('b').text()).toContain(
'.host-000001.group-00000.dummy'

View File

@ -96,7 +96,6 @@ describe('<InventoryGroupsList />', () => {
afterEach(() => {
jest.clearAllMocks();
wrapper.unmount();
});
test('should fetch groups from api and render them in the list', async () => {
@ -201,7 +200,6 @@ describe('<InventoryGroupsList/> error handling', () => {
afterEach(() => {
jest.clearAllMocks();
wrapper.unmount();
});
test('should show content error when api throws error on initial render', async () => {

View File

@ -41,10 +41,6 @@ describe('<InventoryHost />', () => {
});
});
afterEach(() => {
wrapper.unmount();
});
test('should render expected tabs', async () => {
const expectedTabs = [
'Back to Hosts',

View File

@ -100,7 +100,6 @@ describe('<InventoryHostGroupsList />', () => {
afterEach(() => {
jest.clearAllMocks();
wrapper.unmount();
});
test('initially renders successfully', () => {

View File

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

View File

@ -3,6 +3,14 @@ import { createMemoryHistory } from 'history';
import { mountWithContexts } from '../../../../testUtils/enzymeHelpers';
import InventoryHosts from './InventoryHosts';
jest.mock('./InventoryHostList', () => {
const InventoryHostList = () => <div />;
return {
__esModule: true,
default: InventoryHostList,
};
});
describe('<InventoryHosts />', () => {
test('should render inventory host list', () => {
const history = createMemoryHistory({
@ -20,6 +28,5 @@ describe('<InventoryHosts />', () => {
});
expect(wrapper.find('InventoryHostList').length).toBe(1);
wrapper.unmount();
});
});

View File

@ -95,7 +95,6 @@ describe('<InventoryRelatedGroupList />', () => {
afterEach(() => {
jest.clearAllMocks();
wrapper.unmount();
});
test('initially renders successfully ', () => {

View File

@ -72,7 +72,6 @@ describe('<InventorySourceAdd />', () => {
afterEach(() => {
jest.clearAllMocks();
wrapper.unmount();
});
test('new form displays primary form fields', async () => {

View File

@ -23,7 +23,6 @@ const source = {
describe('<InventorySourceListItem />', () => {
let wrapper;
afterEach(() => {
wrapper.unmount();
jest.clearAllMocks();
});

View File

@ -6,6 +6,5 @@ describe('<InventorySources />', () => {
test('initially renders without crashing', () => {
const wrapper = shallow(<InventorySources />);
expect(wrapper.length).toBe(1);
wrapper.unmount();
});
});

View File

@ -22,7 +22,6 @@ describe('<SmartInventory />', () => {
let wrapper;
afterEach(() => {
wrapper.unmount();
jest.clearAllMocks();
});

View File

@ -29,7 +29,6 @@ describe('<SmartInventoryHost />', () => {
let history;
afterEach(() => {
wrapper.unmount();
jest.clearAllMocks();
});

View File

@ -37,7 +37,6 @@ describe('<SmartInventoryHostList />', () => {
afterAll(() => {
jest.clearAllMocks();
wrapper.unmount();
});
test('initially renders successfully', () => {

View File

@ -37,10 +37,6 @@ describe('<SmartInventoryHostListItem />', () => {
);
});
afterEach(() => {
wrapper.unmount();
});
test('should render expected row cells', () => {
const cells = wrapper.find('Td');
expect(cells).toHaveLength(4);

View File

@ -8,6 +8,13 @@ import {
import SmartInventoryHosts from './SmartInventoryHosts';
jest.mock('../../../api');
jest.mock('./SmartInventoryHostList', () => {
const SmartInventoryHostList = () => <div />;
return {
__esModule: true,
default: SmartInventoryHostList,
};
});
describe('<SmartInventoryHosts />', () => {
test('should render smart inventory host list', () => {
@ -26,8 +33,10 @@ describe('<SmartInventoryHosts />', () => {
}
);
expect(wrapper.find('SmartInventoryHostList').length).toBe(1);
expect(wrapper.find('SmartInventoryHostList').prop('inventory')).toEqual({
id: 1,
});
jest.clearAllMocks();
wrapper.unmount();
});
test('should render smart inventory host details', async () => {
@ -51,6 +60,5 @@ describe('<SmartInventoryHosts />', () => {
await waitForElement(wrapper, 'ContentLoading', el => el.length === 0);
expect(wrapper.find('SmartInventoryHost').length).toBe(1);
jest.clearAllMocks();
wrapper.unmount();
});
});

View File

@ -21,7 +21,6 @@ describe('<InventorySourceSyncButton />', () => {
);
});
afterEach(() => {
wrapper.unmount();
jest.clearAllMocks();
});

View File

@ -13,10 +13,6 @@ describe('<HostStatusBar />', () => {
wrapper = mountWithContexts(<HostStatusBar counts={mockCounts} />);
});
afterEach(() => {
wrapper.unmount();
});
test('initially renders without crashing', () => {
expect(wrapper.length).toBe(1);
});

View File

@ -22,10 +22,6 @@ describe('<OutputToolbar />', () => {
);
});
afterEach(() => {
wrapper.unmount();
});
test('initially renders without crashing', () => {
expect(wrapper.length).toBe(1);
});

View File

@ -115,7 +115,6 @@ describe('WorkflowOutput', () => {
afterEach(() => {
jest.clearAllMocks();
wrapper.unmount();
delete window.SVGElement.prototype.getBBox;
delete window.SVGElement.prototype.getBoundingClientRect;
delete window.SVGElement.prototype.height;

View File

@ -44,10 +44,6 @@ describe('WorkflowOutputToolbar', () => {
);
});
afterAll(() => {
wrapper.unmount();
});
test('should render correct toolbar item', () => {
shouldFind(`Button[ouiaId="edit-workflow"]`);
shouldFind('Button#workflow-output-toggle-legend');

View File

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

View File

@ -33,7 +33,6 @@ describe('<Metrics/>', () => {
});
});
afterEach(() => {
wrapper.unmount();
jest.clearAllMocks();
});
test('should mound properly', () => {

View File

@ -2,26 +2,21 @@ import React from 'react';
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
import NotificationTemplates from './NotificationTemplates';
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
}));
jest.mock('./NotificationTemplateList', () => {
const NotificationTemplateList = () => <div />;
return {
__esModule: true,
default: NotificationTemplateList,
};
});
describe('<NotificationTemplates />', () => {
let pageWrapper;
let pageSections;
beforeEach(() => {
pageWrapper = mountWithContexts(<NotificationTemplates />);
pageSections = pageWrapper.find('PageSection');
});
afterEach(() => {
pageWrapper.unmount();
});
test('initially renders without crashing', () => {
expect(pageWrapper.length).toBe(1);
expect(pageSections.length).toBe(2);
const wrapper = mountWithContexts(<NotificationTemplates />);
const pageSections = wrapper.find('PageSection');
expect(pageSections).toHaveLength(1);
expect(pageSections.first().props().variant).toBe('light');
expect(wrapper.find('NotificationTemplateList')).toHaveLength(1);
});
});

View File

@ -1,37 +1,16 @@
import React from 'react';
import { createMemoryHistory } from 'history';
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
import Projects from './Projects';
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
}));
import { shallow } from 'enzyme';
import { _Projects as Projects } from './Projects';
describe('<Projects />', () => {
test('initially renders successfully', () => {
mountWithContexts(<Projects />);
});
test('should display a breadcrumb heading', () => {
const history = createMemoryHistory({
initialEntries: ['/projects'],
});
const match = { path: '/projects', url: '/projects', isExact: true };
const wrapper = shallow(<Projects />);
const wrapper = mountWithContexts(<Projects />, {
context: {
router: {
history,
route: {
location: history.location,
match,
},
},
},
const header = wrapper.find('ScreenHeader');
expect(header.prop('streamType')).toBe('project');
expect(header.prop('breadcrumbConfig')).toEqual({
'/projects': 'Projects',
'/projects/add': 'Create New Project',
});
expect(wrapper.find('Title').length).toBe(1);
wrapper.unmount();
});
});

View File

@ -98,7 +98,6 @@ describe('<ProjectForm />', () => {
});
afterEach(() => {
wrapper.unmount();
jest.clearAllMocks();
});

View File

@ -1,39 +1,15 @@
import React from 'react';
import { createMemoryHistory } from 'history';
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
import { shallow } from 'enzyme';
import AllSchedules from './AllSchedules';
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
}));
describe('<AllSchedules />', () => {
let wrapper;
test('should set breadcrumb config', () => {
const wrapper = shallow(<AllSchedules />);
afterEach(() => {
wrapper.unmount();
});
test('initially renders successfully', () => {
wrapper = mountWithContexts(<AllSchedules />);
});
test('should display schedule list breadcrumb heading', () => {
const history = createMemoryHistory({
initialEntries: ['/schedules'],
const header = wrapper.find('ScreenHeader');
expect(header.prop('streamType')).toEqual('schedule');
expect(header.prop('breadcrumbConfig')).toEqual({
'/schedules': 'Schedules',
});
wrapper = mountWithContexts(<AllSchedules />, {
context: {
router: {
history,
route: {
location: history.location,
},
},
},
});
expect(wrapper.find('Title').text()).toBe('Schedules');
});
});

View File

@ -37,7 +37,6 @@ describe('<JobsDetail />', () => {
});
afterAll(() => {
wrapper.unmount();
jest.clearAllMocks();
});

View File

@ -18,7 +18,6 @@ describe('<LDAP />', () => {
let wrapper;
afterEach(() => {
wrapper.unmount();
jest.clearAllMocks();
});

View File

@ -46,7 +46,6 @@ describe('<LDAPDetail />', () => {
});
afterAll(() => {
wrapper.unmount();
jest.clearAllMocks();
});

View File

@ -39,7 +39,6 @@ describe('<Logging />', () => {
let wrapper;
afterEach(() => {
wrapper.unmount();
jest.clearAllMocks();
});

View File

@ -34,7 +34,6 @@ describe('<LoggingDetail />', () => {
});
afterAll(() => {
wrapper.unmount();
jest.clearAllMocks();
});

View File

@ -20,7 +20,6 @@ describe('<MiscAuthentication />', () => {
});
afterEach(() => {
wrapper.unmount();
jest.clearAllMocks();
});

View File

@ -20,7 +20,6 @@ describe('<MiscSystem />', () => {
});
afterEach(() => {
wrapper.unmount();
jest.clearAllMocks();
});

View File

@ -23,7 +23,6 @@ describe('<RADIUS />', () => {
});
afterEach(() => {
wrapper.unmount();
jest.clearAllMocks();
});

View File

@ -29,7 +29,6 @@ describe('<RADIUSEdit />', () => {
});
afterEach(() => {
wrapper.unmount();
jest.clearAllMocks();
});

View File

@ -54,7 +54,6 @@ describe('<SAMLDetail />', () => {
});
afterAll(() => {
wrapper.unmount();
jest.clearAllMocks();
});

View File

@ -7,9 +7,7 @@ describe('<SettingList />', () => {
beforeEach(() => {
wrapper = mountWithContexts(<SettingList />);
});
afterEach(() => {
wrapper.unmount();
});
test('initially renders without crashing', () => {
expect(wrapper.length).toBe(1);
});

View File

@ -30,7 +30,6 @@ describe('<Settings />', () => {
});
afterEach(() => {
wrapper.unmount();
jest.clearAllMocks();
});

View File

@ -24,7 +24,6 @@ describe('<Subscription />', () => {
let wrapper;
afterEach(() => {
wrapper.unmount();
jest.clearAllMocks();
});

View File

@ -44,10 +44,6 @@ describe('<SubscriptionDetail />', () => {
});
});
afterEach(() => {
wrapper.unmount();
});
test('initially renders without crashing', () => {
expect(wrapper.find('SubscriptionDetail').length).toBe(1);
});

View File

@ -29,7 +29,6 @@ describe('<AnalyticsStep />', () => {
afterEach(() => {
jest.clearAllMocks();
wrapper.unmount();
});
test('initially renders without crashing', async () => {

View File

@ -29,7 +29,6 @@ describe('<EulaStep />', () => {
afterEach(() => {
jest.clearAllMocks();
wrapper.unmount();
});
test('initially renders without crashing', async () => {

View File

@ -54,7 +54,6 @@ describe('<SubscriptionModal />', () => {
afterAll(() => {
jest.clearAllMocks();
wrapper.unmount();
});
test('initially renders without crashing', async () => {

View File

@ -29,7 +29,6 @@ describe('<SubscriptionStep />', () => {
afterAll(() => {
jest.clearAllMocks();
wrapper.unmount();
});
test('initially renders without crashing', async () => {

View File

@ -22,7 +22,6 @@ describe('<TACACS />', () => {
let wrapper;
afterEach(() => {
wrapper.unmount();
jest.clearAllMocks();
});

View File

@ -39,7 +39,6 @@ describe('<TACACSDetail />', () => {
});
afterAll(() => {
wrapper.unmount();
jest.clearAllMocks();
});

View File

@ -31,7 +31,6 @@ describe('<TACACSEdit />', () => {
});
afterEach(() => {
wrapper.unmount();
jest.clearAllMocks();
});

View File

@ -23,7 +23,6 @@ describe('<UI />', () => {
let wrapper;
afterEach(() => {
wrapper.unmount();
jest.clearAllMocks();
});

View File

@ -37,7 +37,6 @@ describe('<UIDetail />', () => {
});
afterAll(() => {
wrapper.unmount();
jest.clearAllMocks();
});

View File

@ -29,7 +29,6 @@ describe('<UIEdit />', () => {
});
afterEach(() => {
wrapper.unmount();
jest.clearAllMocks();
});

View File

@ -8,6 +8,5 @@ describe('RevertAllAlert', () => {
<RevertAllAlert onClose={() => {}} onRevertAll={() => {}} />
);
expect(wrapper).toHaveLength(1);
wrapper.unmount();
});
});

View File

@ -7,10 +7,6 @@ import RevertButton from './RevertButton';
describe('RevertButton', () => {
let wrapper;
afterEach(() => {
wrapper.unmount();
});
test('button text should display "Revert"', async () => {
wrapper = mountWithContexts(
<Formik

View File

@ -12,6 +12,5 @@ describe('RevertFormActionGroup', () => {
/>
);
expect(wrapper).toHaveLength(1);
wrapper.unmount();
});
});

View File

@ -33,10 +33,6 @@ describe('<TeamDetail />', () => {
await waitForElement(wrapper, 'ContentLoading', el => el.length === 0);
});
afterEach(() => {
wrapper.unmount();
});
test('initially renders successfully', async () => {
await waitForElement(wrapper, 'TeamDetail');
});

View File

@ -175,7 +175,6 @@ describe('<TeamRolesList />', () => {
afterEach(() => {
jest.clearAllMocks();
wrapper.unmount();
});
test('should render properly', async () => {
TeamsAPI.readRoles.mockResolvedValue(roles);

View File

@ -30,7 +30,6 @@ describe('<TeamForm />', () => {
};
afterEach(() => {
wrapper.unmount();
jest.clearAllMocks();
});

View File

@ -75,12 +75,6 @@ describe('<SurveyPreviewModal />', () => {
});
waitForElement(wrapper, 'Form');
});
afterAll(() => {
wrapper.unmount();
});
test('renders successfully', async () => {
expect(wrapper.find('SurveyPreviewModal').length).toBe(1);
});
test('Renders proper fields', async () => {
const question1 = wrapper.find('FormGroup[label="Text Question"]');

View File

@ -55,10 +55,6 @@ describe('<SurveyQuestionEdit />', () => {
});
});
afterEach(() => {
wrapper.unmount();
});
test('should render form', () => {
expect(wrapper.find('SurveyQuestionForm')).toHaveLength(1);
});
@ -149,8 +145,6 @@ describe('<SurveyQuestionEdit />', () => {
expect(history.location.pathname).toEqual(
'/templates/job_templates/1/survey'
);
wrapper.unmount();
});
});
});

View File

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

View File

@ -23,6 +23,7 @@ describe('<WebhookSubForm />', () => {
webhook_service: 'github',
webhook_key: 'webhook key',
};
beforeEach(async () => {
history = createMemoryHistory({
initialEntries: ['templates/job_template/51/edit'],
@ -51,13 +52,11 @@ describe('<WebhookSubForm />', () => {
);
});
});
afterEach(() => {
jest.clearAllMocks();
wrapper.unmount();
});
test('mounts properly', () => {
expect(wrapper.length).toBe(1);
});
test('should render initial values properly', () => {
waitForElement(wrapper, 'Lookup__ChipHolder', el => el.lenth > 0);
expect(wrapper.find('AnsibleSelect').prop('value')).toBe('github');
@ -73,6 +72,7 @@ describe('<WebhookSubForm />', () => {
'Github credential'
);
});
test('should make other credential type available', async () => {
CredentialsAPI.read.mockResolvedValue({
data: { results: [{ id: 13, name: 'GitLab credential' }] },
@ -93,6 +93,7 @@ describe('<WebhookSubForm />', () => {
.prop('value')
).toBe('A NEW WEBHOOK KEY WILL BE GENERATED ON SAVE.');
});
test('should have disabled button to update webhook key', async () => {
let newWrapper;
await act(async () => {