remove 4th batch of unmount() calls

This commit is contained in:
Keith J. Grant
2021-07-09 11:36:23 -07:00
parent 81c16f4fa7
commit 0185269d97
33 changed files with 53 additions and 128 deletions

View File

@@ -16,7 +16,6 @@ jest.mock('../../api/models/Users');
jest.mock('react-router-dom', () => ({ jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'), ...jest.requireActual('react-router-dom'),
useHistory: () => ({ push: jest.fn(), location: { pathname: {} } }), useHistory: () => ({ push: jest.fn(), location: { pathname: {} } }),
})); }));
// TODO: Once error handling is functional in // TODO: Once error handling is functional in

View File

@@ -5,10 +5,6 @@ import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
import ScreenHeader from './ScreenHeader'; import ScreenHeader from './ScreenHeader';
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
}));
describe('<ScreenHeader />', () => { describe('<ScreenHeader />', () => {
let breadcrumbWrapper; let breadcrumbWrapper;
let breadcrumb; let breadcrumb;

View File

@@ -15,6 +15,7 @@ jest.mock('react-router-dom', () => ({
}), }),
useParams: () => ({ id: 1 }), useParams: () => ({ id: 1 }),
})); }));
const options = { const options = {
data: { data: {
actions: { actions: {

View File

@@ -11,10 +11,6 @@ import Settings from './Settings';
jest.mock('../../api'); jest.mock('../../api');
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
}));
describe('<Settings />', () => { describe('<Settings />', () => {
let wrapper; let wrapper;

View File

@@ -50,10 +50,11 @@ describe('<WorkflowJobTemplate />', () => {
}, },
}); });
}); });
afterEach(() => { afterEach(() => {
jest.clearAllMocks(); jest.clearAllMocks();
wrapper.unmount();
}); });
test('initially renders successfully', async () => { test('initially renders successfully', async () => {
await act(async () => { await act(async () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
@@ -61,6 +62,7 @@ describe('<WorkflowJobTemplate />', () => {
); );
}); });
}); });
test('When component mounts API is called and the response is put in state', async () => { test('When component mounts API is called and the response is put in state', async () => {
await act(async () => { await act(async () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
@@ -70,6 +72,7 @@ describe('<WorkflowJobTemplate />', () => {
expect(WorkflowJobTemplatesAPI.readDetail).toBeCalled(); expect(WorkflowJobTemplatesAPI.readDetail).toBeCalled();
expect(OrganizationsAPI.read).toBeCalled(); expect(OrganizationsAPI.read).toBeCalled();
}); });
test('notifications tab shown for admins', async () => { test('notifications tab shown for admins', async () => {
await act(async () => { await act(async () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
@@ -84,6 +87,7 @@ describe('<WorkflowJobTemplate />', () => {
); );
expect(tabs.at(3).text()).toEqual('Notifications'); expect(tabs.at(3).text()).toEqual('Notifications');
}); });
test('notifications tab hidden with reduced permissions', async () => { test('notifications tab hidden with reduced permissions', async () => {
OrganizationsAPI.read.mockResolvedValue({ OrganizationsAPI.read.mockResolvedValue({
data: { data: {
@@ -135,6 +139,7 @@ describe('<WorkflowJobTemplate />', () => {
await waitForElement(wrapper, 'ContentError', el => el.length === 1); await waitForElement(wrapper, 'ContentError', el => el.length === 1);
}); });
test('should call to get webhook key', async () => { test('should call to get webhook key', async () => {
const history = createMemoryHistory({ const history = createMemoryHistory({
initialEntries: ['/templates/workflow_job_template/1/foobar'], initialEntries: ['/templates/workflow_job_template/1/foobar'],
@@ -161,6 +166,7 @@ describe('<WorkflowJobTemplate />', () => {
}); });
expect(WorkflowJobTemplatesAPI.readWebhookKey).toHaveBeenCalled(); expect(WorkflowJobTemplatesAPI.readWebhookKey).toHaveBeenCalled();
}); });
test('should not call to get webhook key', async () => { test('should not call to get webhook key', async () => {
WorkflowJobTemplatesAPI.readWorkflowJobTemplateOptions.mockResolvedValueOnce( WorkflowJobTemplatesAPI.readWorkflowJobTemplateOptions.mockResolvedValueOnce(
{ {

View File

@@ -15,10 +15,6 @@ describe('DeleteAllNodesModal', () => {
); );
}); });
afterAll(() => {
wrapper.unmount();
});
test('Delete All button dispatches as expected', () => { test('Delete All button dispatches as expected', () => {
wrapper.find('button#confirm-delete-all-nodes').simulate('click'); wrapper.find('button#confirm-delete-all-nodes').simulate('click');
expect(dispatch).toHaveBeenCalledWith({ expect(dispatch).toHaveBeenCalledWith({

View File

@@ -32,10 +32,6 @@ describe('LinkDeleteModal', () => {
); );
}); });
afterAll(() => {
wrapper.unmount();
});
test('Confirm button dispatches as expected', () => { test('Confirm button dispatches as expected', () => {
wrapper.find('button#confirm-link-removal').simulate('click'); wrapper.find('button#confirm-link-removal').simulate('click');
expect(dispatch).toHaveBeenCalledWith({ expect(dispatch).toHaveBeenCalledWith({

View File

@@ -27,10 +27,6 @@ describe('LinkModal', () => {
); );
}); });
afterAll(() => {
wrapper.unmount();
});
test('Dropdown defaults to success when adding new link', () => { test('Dropdown defaults to success when adding new link', () => {
expect(wrapper.find('AnsibleSelect').prop('value')).toBe('success'); expect(wrapper.find('AnsibleSelect').prop('value')).toBe('success');
}); });
@@ -57,6 +53,7 @@ describe('LinkModal', () => {
expect(onConfirm).toHaveBeenCalledWith('always'); expect(onConfirm).toHaveBeenCalledWith('always');
}); });
}); });
describe('Editing existing link', () => { describe('Editing existing link', () => {
test('Dropdown defaults to existing link type when editing link', () => { test('Dropdown defaults to existing link type when editing link', () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
@@ -79,7 +76,6 @@ describe('LinkModal', () => {
</WorkflowDispatchContext.Provider> </WorkflowDispatchContext.Provider>
); );
expect(wrapper.find('AnsibleSelect').prop('value')).toBe('failure'); expect(wrapper.find('AnsibleSelect').prop('value')).toBe('failure');
wrapper.unmount();
}); });
}); });
}); });

View File

@@ -32,10 +32,6 @@ describe('NodeDeleteModal', () => {
); );
}); });
afterAll(() => {
wrapper.unmount();
});
test('Mounts successfully', () => { test('Mounts successfully', () => {
expect(wrapper.length).toBe(1); expect(wrapper.length).toBe(1);
}); });
@@ -63,6 +59,7 @@ describe('NodeDeleteModal', () => {
}); });
}); });
}); });
describe('Node without unified job template', () => { describe('Node without unified job template', () => {
test('Mounts successfully', () => { test('Mounts successfully', () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
@@ -79,7 +76,6 @@ describe('NodeDeleteModal', () => {
</WorkflowDispatchContext.Provider> </WorkflowDispatchContext.Provider>
); );
expect(wrapper.length).toBe(1); expect(wrapper.length).toBe(1);
wrapper.unmount();
}); });
}); });
}); });

View File

@@ -28,10 +28,6 @@ describe('NodeNextButton', () => {
); );
}); });
afterAll(() => {
wrapper.unmount();
});
test('Button text matches', () => { test('Button text matches', () => {
expect(wrapper.find('button').text()).toBe(buttonText); expect(wrapper.find('button').text()).toBe(buttonText);
}); });

View File

@@ -15,9 +15,6 @@ const onUpdateNodeResource = jest.fn();
describe('InventorySourcesList', () => { describe('InventorySourcesList', () => {
let wrapper; let wrapper;
afterEach(() => {
wrapper.unmount();
});
test('Row selected when nodeResource id matches row id and clicking new row makes expected callback', async () => { test('Row selected when nodeResource id matches row id and clicking new row makes expected callback', async () => {
InventorySourcesAPI.read.mockResolvedValueOnce({ InventorySourcesAPI.read.mockResolvedValueOnce({
data: { data: {
@@ -74,6 +71,7 @@ describe('InventorySourcesList', () => {
url: '/api/v2/inventory_sources/2', url: '/api/v2/inventory_sources/2',
}); });
}); });
test('Error shown when read() request errors', async () => { test('Error shown when read() request errors', async () => {
InventorySourcesAPI.read.mockRejectedValue(new Error()); InventorySourcesAPI.read.mockRejectedValue(new Error());
await act(async () => { await act(async () => {

View File

@@ -17,8 +17,8 @@ describe('JobTemplatesList', () => {
let wrapper; let wrapper;
afterEach(() => { afterEach(() => {
jest.clearAllMocks(); jest.clearAllMocks();
wrapper.unmount();
}); });
test('Row selected when nodeResource id matches row id and clicking new row makes expected callback', async () => { test('Row selected when nodeResource id matches row id and clicking new row makes expected callback', async () => {
JobTemplatesAPI.read.mockResolvedValueOnce({ JobTemplatesAPI.read.mockResolvedValueOnce({
data: { data: {
@@ -81,6 +81,7 @@ describe('JobTemplatesList', () => {
project: 2, project: 2,
}); });
}); });
test('Error shown when read() request errors', async () => { test('Error shown when read() request errors', async () => {
JobTemplatesAPI.read.mockRejectedValue(new Error()); JobTemplatesAPI.read.mockRejectedValue(new Error());
JobTemplatesAPI.readOptions.mockResolvedValue({ JobTemplatesAPI.readOptions.mockResolvedValue({

View File

@@ -15,9 +15,7 @@ const onUpdateNodeResource = jest.fn();
describe('ProjectsList', () => { describe('ProjectsList', () => {
let wrapper; let wrapper;
afterEach(() => {
wrapper.unmount();
});
test('Row selected when nodeResource id matches row id and clicking new row makes expected callback', async () => { test('Row selected when nodeResource id matches row id and clicking new row makes expected callback', async () => {
ProjectsAPI.read.mockResolvedValueOnce({ ProjectsAPI.read.mockResolvedValueOnce({
data: { data: {
@@ -70,6 +68,7 @@ describe('ProjectsList', () => {
url: '/api/v2/projects/2', url: '/api/v2/projects/2',
}); });
}); });
test('Error shown when read() request errors', async () => { test('Error shown when read() request errors', async () => {
ProjectsAPI.read.mockRejectedValue(new Error()); ProjectsAPI.read.mockRejectedValue(new Error());
await act(async () => { await act(async () => {

View File

@@ -15,9 +15,7 @@ const onUpdateNodeResource = jest.fn();
describe('WorkflowJobTemplatesList', () => { describe('WorkflowJobTemplatesList', () => {
let wrapper; let wrapper;
afterEach(() => {
wrapper.unmount();
});
test('Row selected when nodeResource id matches row id and clicking new row makes expected callback', async () => { test('Row selected when nodeResource id matches row id and clicking new row makes expected callback', async () => {
WorkflowJobTemplatesAPI.read.mockResolvedValueOnce({ WorkflowJobTemplatesAPI.read.mockResolvedValueOnce({
data: { data: {
@@ -76,6 +74,7 @@ describe('WorkflowJobTemplatesList', () => {
url: '/api/v2/workflow_job_templates/2', url: '/api/v2/workflow_job_templates/2',
}); });
}); });
test('Error shown when read() request errors', async () => { test('Error shown when read() request errors', async () => {
WorkflowJobTemplatesAPI.read.mockRejectedValue(new Error()); WorkflowJobTemplatesAPI.read.mockRejectedValue(new Error());
await act(async () => { await act(async () => {

View File

@@ -85,7 +85,6 @@ describe('NodeViewModal', () => {
afterAll(() => { afterAll(() => {
jest.resetAllMocks(); jest.resetAllMocks();
wrapper.unmount();
}); });
test('should render prompt detail', () => { test('should render prompt detail', () => {
@@ -151,7 +150,6 @@ describe('NodeViewModal', () => {
expect(JobTemplatesAPI.readWebhookKey).not.toHaveBeenCalledWith(); expect(JobTemplatesAPI.readWebhookKey).not.toHaveBeenCalledWith();
expect(JobTemplatesAPI.readLaunch).toHaveBeenCalledWith(1); expect(JobTemplatesAPI.readLaunch).toHaveBeenCalledWith(1);
expect(JobTemplatesAPI.readInstanceGroups).toHaveBeenCalledTimes(1); expect(JobTemplatesAPI.readInstanceGroups).toHaveBeenCalledTimes(1);
wrapper.unmount();
jest.clearAllMocks(); jest.clearAllMocks();
}); });
@@ -169,7 +167,6 @@ describe('NodeViewModal', () => {
}); });
waitForLoaded(wrapper); waitForLoaded(wrapper);
expect(wrapper.find('ContentError').length).toBe(1); expect(wrapper.find('ContentError').length).toBe(1);
wrapper.unmount();
jest.clearAllMocks(); jest.clearAllMocks();
}); });
@@ -186,7 +183,6 @@ describe('NodeViewModal', () => {
}); });
waitForLoaded(wrapper); waitForLoaded(wrapper);
expect(wrapper.find('Button#node-view-edit-button').length).toBe(1); expect(wrapper.find('Button#node-view-edit-button').length).toBe(1);
wrapper.unmount();
jest.clearAllMocks(); jest.clearAllMocks();
}); });
@@ -203,7 +199,6 @@ describe('NodeViewModal', () => {
}); });
waitForLoaded(wrapper); waitForLoaded(wrapper);
expect(wrapper.find('Button#node-view-edit-button').length).toBe(0); expect(wrapper.find('Button#node-view-edit-button').length).toBe(0);
wrapper.unmount();
jest.clearAllMocks(); jest.clearAllMocks();
}); });
}); });
@@ -237,7 +232,6 @@ describe('NodeViewModal', () => {
expect(WorkflowJobTemplatesAPI.readLaunch).not.toHaveBeenCalled(); expect(WorkflowJobTemplatesAPI.readLaunch).not.toHaveBeenCalled();
expect(JobTemplatesAPI.readLaunch).not.toHaveBeenCalled(); expect(JobTemplatesAPI.readLaunch).not.toHaveBeenCalled();
expect(JobTemplatesAPI.readInstanceGroups).not.toHaveBeenCalled(); expect(JobTemplatesAPI.readInstanceGroups).not.toHaveBeenCalled();
wrapper.unmount();
jest.clearAllMocks(); jest.clearAllMocks();
}); });
}); });
@@ -271,7 +265,6 @@ describe('NodeViewModal', () => {
expect(WorkflowJobTemplatesAPI.readLaunch).not.toHaveBeenCalled(); expect(WorkflowJobTemplatesAPI.readLaunch).not.toHaveBeenCalled();
expect(JobTemplatesAPI.readLaunch).not.toHaveBeenCalled(); expect(JobTemplatesAPI.readLaunch).not.toHaveBeenCalled();
expect(JobTemplatesAPI.readInstanceGroups).not.toHaveBeenCalled(); expect(JobTemplatesAPI.readInstanceGroups).not.toHaveBeenCalled();
wrapper.unmount();
jest.clearAllMocks(); jest.clearAllMocks();
}); });
}); });
@@ -305,7 +298,6 @@ describe('NodeViewModal', () => {
expect(WorkflowJobTemplatesAPI.readLaunch).not.toHaveBeenCalled(); expect(WorkflowJobTemplatesAPI.readLaunch).not.toHaveBeenCalled();
expect(JobTemplatesAPI.readLaunch).not.toHaveBeenCalled(); expect(JobTemplatesAPI.readLaunch).not.toHaveBeenCalled();
expect(JobTemplatesAPI.readInstanceGroups).not.toHaveBeenCalled(); expect(JobTemplatesAPI.readInstanceGroups).not.toHaveBeenCalled();
wrapper.unmount();
jest.clearAllMocks(); jest.clearAllMocks();
}); });
}); });

View File

@@ -16,10 +16,6 @@ describe('RunStep', () => {
); );
}); });
afterAll(() => {
wrapper.unmount();
});
test('Default selected card matches default link type when present', () => { test('Default selected card matches default link type when present', () => {
expect(wrapper.find('#link-type-success').props().isSelected).toBe(true); expect(wrapper.find('#link-type-success').props().isSelected).toBe(true);
expect(wrapper.find('#link-type-failure').props().isSelected).toBe(false); expect(wrapper.find('#link-type-failure').props().isSelected).toBe(false);

View File

@@ -17,10 +17,6 @@ describe('UnsavedChangesModal', () => {
); );
}); });
afterAll(() => {
wrapper.unmount();
});
test('Exit Without Saving button dispatches as expected', () => { test('Exit Without Saving button dispatches as expected', () => {
wrapper.find('button#confirm-exit-without-saving').simulate('click'); wrapper.find('button#confirm-exit-without-saving').simulate('click');
expect(onExit).toHaveBeenCalled(); expect(onExit).toHaveBeenCalled();

View File

@@ -141,7 +141,6 @@ describe('Visualizer', () => {
}); });
afterAll(() => { afterAll(() => {
wrapper.unmount();
delete window.SVGElement.prototype.getBBox; delete window.SVGElement.prototype.getBBox;
delete window.SVGElement.prototype.getBoundingClientRect; delete window.SVGElement.prototype.getBoundingClientRect;
delete window.SVGElement.prototype.height; delete window.SVGElement.prototype.height;

View File

@@ -62,9 +62,6 @@ describe('VisualizerLink', () => {
</WorkflowDispatchContext.Provider> </WorkflowDispatchContext.Provider>
); );
}); });
afterAll(() => {
wrapper.unmount();
});
test('Displays action tooltip on hover and updates help text on hover', () => { test('Displays action tooltip on hover and updates help text on hover', () => {
expect(wrapper.find('WorkflowActionTooltip').length).toBe(0); expect(wrapper.find('WorkflowActionTooltip').length).toBe(0);

View File

@@ -73,12 +73,11 @@ describe('VisualizerNode', () => {
afterEach(() => { afterEach(() => {
jest.clearAllMocks(); jest.clearAllMocks();
}); });
afterAll(() => {
wrapper.unmount();
});
test('Displays unified job template name inside node', () => { test('Displays unified job template name inside node', () => {
expect(wrapper.find('NodeResourceName').text()).toBe('Automation JT'); expect(wrapper.find('NodeResourceName').text()).toBe('Automation JT');
}); });
test('Displays action tooltip on hover and updates help text on hover', () => { test('Displays action tooltip on hover and updates help text on hover', () => {
expect(wrapper.find('WorkflowActionTooltip').length).toBe(0); expect(wrapper.find('WorkflowActionTooltip').length).toBe(0);
wrapper.find('g').simulate('mouseenter'); wrapper.find('g').simulate('mouseenter');
@@ -234,9 +233,7 @@ describe('VisualizerNode', () => {
</WorkflowDispatchContext.Provider> </WorkflowDispatchContext.Provider>
); );
}); });
afterAll(() => {
wrapper.unmount();
});
test('Displays correct help text when hovering over node while adding link', () => { test('Displays correct help text when hovering over node while adding link', () => {
expect(wrapper.find('WorkflowActionTooltip').length).toBe(0); expect(wrapper.find('WorkflowActionTooltip').length).toBe(0);
wrapper.find('g').simulate('mouseenter'); wrapper.find('g').simulate('mouseenter');
@@ -248,6 +245,7 @@ describe('VisualizerNode', () => {
expect(wrapper.find('WorkflowActionTooltip').length).toBe(0); expect(wrapper.find('WorkflowActionTooltip').length).toBe(0);
expect(updateHelpText).toHaveBeenCalledWith(null); expect(updateHelpText).toHaveBeenCalledWith(null);
}); });
test('Dispatches properly when node is clicked', () => { test('Dispatches properly when node is clicked', () => {
wrapper wrapper
.find('foreignObject') .find('foreignObject')
@@ -259,6 +257,7 @@ describe('VisualizerNode', () => {
}); });
}); });
}); });
describe('Node without unified job template', () => { describe('Node without unified job template', () => {
test('Displays DELETED text inside node when unified job template is missing', () => { test('Displays DELETED text inside node when unified job template is missing', () => {
const wrapper = mountWithContexts( const wrapper = mountWithContexts(
@@ -279,6 +278,7 @@ describe('VisualizerNode', () => {
expect(wrapper.find('NodeResourceName').text()).toBe('DELETED'); expect(wrapper.find('NodeResourceName').text()).toBe('DELETED');
}); });
}); });
describe('Node without full unified job template', () => { describe('Node without full unified job template', () => {
let wrapper; let wrapper;
beforeEach(() => { beforeEach(() => {
@@ -336,9 +336,7 @@ describe('VisualizerNode', () => {
</WorkflowDispatchContext.Provider> </WorkflowDispatchContext.Provider>
); );
}); });
afterEach(() => {
wrapper.unmount();
});
test('Attempts to fetch full unified job template on view', async () => { test('Attempts to fetch full unified job template on view', async () => {
wrapper.find('g').simulate('mouseenter'); wrapper.find('g').simulate('mouseenter');
await act(async () => { await act(async () => {
@@ -348,6 +346,7 @@ describe('VisualizerNode', () => {
}); });
expect(JobTemplatesAPI.readDetail).toHaveBeenCalledWith(7); expect(JobTemplatesAPI.readDetail).toHaveBeenCalledWith(7);
}); });
test('Displays error fetching full unified job template', async () => { test('Displays error fetching full unified job template', async () => {
JobTemplatesAPI.readDetail.mockRejectedValueOnce( JobTemplatesAPI.readDetail.mockRejectedValueOnce(
new Error({ new Error({
@@ -371,6 +370,7 @@ describe('VisualizerNode', () => {
wrapper.update(); wrapper.update();
expect(wrapper.find('AlertModal').length).toBe(1); expect(wrapper.find('AlertModal').length).toBe(1);
}); });
test('Attempts to fetch credentials on view', async () => { test('Attempts to fetch credentials on view', async () => {
JobTemplatesAPI.readDetail.mockResolvedValueOnce({ JobTemplatesAPI.readDetail.mockResolvedValueOnce({
data: { data: {

View File

@@ -54,10 +54,6 @@ describe('VisualizerToolbar', () => {
); );
}); });
afterAll(() => {
wrapper.unmount();
});
test('Shows correct number of nodes', () => { test('Shows correct number of nodes', () => {
// The start node (id=1) and deleted nodes (isDeleted=true) should be ignored // The start node (id=1) and deleted nodes (isDeleted=true) should be ignored
expect(wrapper.find('Badge').text()).toBe('1'); expect(wrapper.find('Badge').text()).toBe('1');

View File

@@ -16,10 +16,6 @@ i18n.activate('en');
let wrapper; let wrapper;
afterEach(() => {
wrapper.unmount();
});
describe('UserListItem with full permissions', () => { describe('UserListItem with full permissions', () => {
beforeEach(() => { beforeEach(() => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
@@ -39,9 +35,11 @@ describe('UserListItem with full permissions', () => {
</I18nProvider> </I18nProvider>
); );
}); });
test('initially renders successfully', () => { test('initially renders successfully', () => {
expect(wrapper.length).toBe(1); expect(wrapper.length).toBe(1);
}); });
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();
}); });

View File

@@ -94,6 +94,7 @@ const roles = {
}; };
describe('<UserRolesList />', () => { describe('<UserRolesList />', () => {
let wrapper;
beforeEach(() => { beforeEach(() => {
UsersAPI.readOptions.mockResolvedValue({ UsersAPI.readOptions.mockResolvedValue({
data: { data: {
@@ -102,11 +103,11 @@ describe('<UserRolesList />', () => {
}, },
}); });
}); });
let wrapper;
afterEach(() => { afterEach(() => {
jest.clearAllMocks(); jest.clearAllMocks();
wrapper.unmount();
}); });
test('should render properly', async () => { test('should render properly', async () => {
UsersAPI.readRoles.mockResolvedValue(roles); UsersAPI.readRoles.mockResolvedValue(roles);

View File

@@ -118,7 +118,6 @@ describe('<UserTeamList />', () => {
afterEach(() => { afterEach(() => {
jest.clearAllMocks(); jest.clearAllMocks();
wrapper.unmount();
}); });
test('should load and render teams', async () => { test('should load and render teams', async () => {

View File

@@ -22,9 +22,9 @@ const onSuccessfulAdd = jest.fn();
describe('<UserTokenAdd />', () => { describe('<UserTokenAdd />', () => {
afterEach(() => { afterEach(() => {
wrapper.unmount();
jest.clearAllMocks(); jest.clearAllMocks();
}); });
test('handleSubmit should post to api', async () => { test('handleSubmit should post to api', async () => {
await act(async () => { await act(async () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(

View File

@@ -8,10 +8,6 @@ import UserTokens from './UserTokens';
describe('<UserTokens />', () => { describe('<UserTokens />', () => {
let wrapper; let wrapper;
afterEach(() => {
wrapper.unmount();
});
test('renders successfully', () => { test('renders successfully', () => {
wrapper = mountWithContexts(<UserTokens />); wrapper = mountWithContexts(<UserTokens />);
expect(wrapper.length).toBe(1); expect(wrapper.length).toBe(1);

View File

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

View File

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

View File

@@ -28,9 +28,7 @@ const applications = {
}; };
describe('<UserTokenForm />', () => { describe('<UserTokenForm />', () => {
let wrapper; let wrapper;
beforeEach(() => {});
afterEach(() => { afterEach(() => {
wrapper.unmount();
jest.clearAllMocks(); jest.clearAllMocks();
}); });

View File

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

View File

@@ -9,9 +9,6 @@ jest.mock('../../../api/models/WorkflowApprovals');
describe('<WorkflowApprovalListItem />', () => { describe('<WorkflowApprovalListItem />', () => {
let wrapper; let wrapper;
afterEach(() => {
wrapper.unmount();
});
test('should display never expires status', () => { test('should display never expires status', () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
@@ -28,6 +25,7 @@ describe('<WorkflowApprovalListItem />', () => {
); );
expect(wrapper.find('Label[children="Never expires"]').length).toBe(1); expect(wrapper.find('Label[children="Never expires"]').length).toBe(1);
}); });
test('should display timed out status', () => { test('should display timed out status', () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
<table> <table>
@@ -47,6 +45,7 @@ describe('<WorkflowApprovalListItem />', () => {
); );
expect(wrapper.find('Label[children="Timed out"]').length).toBe(1); expect(wrapper.find('Label[children="Timed out"]').length).toBe(1);
}); });
test('should display canceled status', () => { test('should display canceled status', () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
<table> <table>
@@ -66,6 +65,7 @@ describe('<WorkflowApprovalListItem />', () => {
); );
expect(wrapper.find('Label[children="Canceled"]').length).toBe(1); expect(wrapper.find('Label[children="Canceled"]').length).toBe(1);
}); });
test('should display approved status', () => { test('should display approved status', () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
<table> <table>
@@ -93,6 +93,7 @@ describe('<WorkflowApprovalListItem />', () => {
); );
expect(wrapper.find('Label[children="Approved"]').length).toBe(1); expect(wrapper.find('Label[children="Approved"]').length).toBe(1);
}); });
test('should display denied status', () => { test('should display denied status', () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
<table> <table>

View File

@@ -11,10 +11,6 @@ import mockWorkflowApprovals from './data.workflowApprovals.json';
jest.mock('../../api'); jest.mock('../../api');
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
}));
describe('<WorkflowApprovals />', () => { describe('<WorkflowApprovals />', () => {
beforeEach(() => { beforeEach(() => {
WorkflowApprovalsAPI.read.mockResolvedValue({ WorkflowApprovalsAPI.read.mockResolvedValue({
@@ -70,6 +66,5 @@ describe('<WorkflowApprovals />', () => {
await waitForElement(wrapper, 'ContentLoading', el => el.length === 0); await waitForElement(wrapper, 'ContentLoading', el => el.length === 0);
expect(wrapper.find('Title').length).toBe(1); expect(wrapper.find('Title').length).toBe(1);
wrapper.unmount();
}); });
}); });

View File

@@ -8,15 +8,14 @@ const workflowApproval = mockWorkflowApprovals.results[0];
describe('<WorkflowApprovalStatus />', () => { describe('<WorkflowApprovalStatus />', () => {
let wrapper; let wrapper;
afterEach(() => {
wrapper.unmount();
});
test('shows no expiration when approval status is pending and no approval_expiration', () => { test('shows no expiration when approval status is pending and no approval_expiration', () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
<WorkflowApprovalStatus workflowApproval={workflowApproval} /> <WorkflowApprovalStatus workflowApproval={workflowApproval} />
); );
expect(wrapper.text()).toBe('Never expires'); expect(wrapper.text()).toBe('Never expires');
}); });
test('shows expiration date/time when approval status is pending and approval_expiration present', () => { test('shows expiration date/time when approval status is pending and approval_expiration present', () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
<WorkflowApprovalStatus <WorkflowApprovalStatus
@@ -30,6 +29,7 @@ describe('<WorkflowApprovalStatus />', () => {
`Expires on ${formatDateString('2020-10-10T17:13:12.067947Z')}` `Expires on ${formatDateString('2020-10-10T17:13:12.067947Z')}`
); );
}); });
test('shows when an approval has timed out', () => { test('shows when an approval has timed out', () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
<WorkflowApprovalStatus <WorkflowApprovalStatus
@@ -42,6 +42,7 @@ describe('<WorkflowApprovalStatus />', () => {
); );
expect(wrapper.find('Label').text()).toBe('Timed out'); expect(wrapper.find('Label').text()).toBe('Timed out');
}); });
test('shows when an approval has canceled', () => { test('shows when an approval has canceled', () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
<WorkflowApprovalStatus <WorkflowApprovalStatus
@@ -54,6 +55,7 @@ describe('<WorkflowApprovalStatus />', () => {
); );
expect(wrapper.find('Label').text()).toBe('Canceled'); expect(wrapper.find('Label').text()).toBe('Canceled');
}); });
test('shows when an approval has approved', () => { test('shows when an approval has approved', () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
<WorkflowApprovalStatus <WorkflowApprovalStatus
@@ -73,6 +75,7 @@ describe('<WorkflowApprovalStatus />', () => {
); );
expect(wrapper.find('Label').text()).toBe('Approved'); expect(wrapper.find('Label').text()).toBe('Approved');
}); });
test('shows when an approval has denied', () => { test('shows when an approval has denied', () => {
wrapper = mountWithContexts( wrapper = mountWithContexts(
<WorkflowApprovalStatus <WorkflowApprovalStatus