mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 18:09:57 -03:30
remove 1st batch of unnecessary unmount calls
This commit is contained in:
parent
58d64045a1
commit
86fcfdf69a
@ -31,6 +31,5 @@ describe('<App />', () => {
|
||||
});
|
||||
expect(wrapper.length).toBe(1);
|
||||
jest.clearAllMocks();
|
||||
wrapper.unmount();
|
||||
});
|
||||
});
|
||||
|
||||
@ -76,8 +76,8 @@ describe('<AdHocCommands />', () => {
|
||||
});
|
||||
});
|
||||
let wrapper;
|
||||
|
||||
afterEach(() => {
|
||||
wrapper.unmount();
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
|
||||
@ -54,7 +54,6 @@ describe('<AdHocCommandsWizard/>', () => {
|
||||
});
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('should mount properly', async () => {
|
||||
|
||||
@ -36,7 +36,6 @@ describe('<AdHocCredentialStep />', () => {
|
||||
});
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('should mount properly', async () => {
|
||||
|
||||
@ -33,9 +33,9 @@ describe('<AdHocExecutionEnvironmentStep />', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('should mount properly', async () => {
|
||||
|
||||
@ -34,6 +34,7 @@ describe('<SelectRoleStep />', () => {
|
||||
name: 'foo',
|
||||
},
|
||||
];
|
||||
|
||||
test('initially renders without crashing', () => {
|
||||
wrapper = shallowWithContexts(
|
||||
<SelectRoleStep
|
||||
@ -43,8 +44,8 @@ describe('<SelectRoleStep />', () => {
|
||||
/>
|
||||
);
|
||||
expect(wrapper.length).toBe(1);
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('clicking role fires onRolesClick callback', () => {
|
||||
const onRolesClick = jest.fn();
|
||||
wrapper = mountWithContexts(
|
||||
@ -63,6 +64,5 @@ describe('<SelectRoleStep />', () => {
|
||||
name: 'Project Admin',
|
||||
description: 'Can manage all projects of the organization',
|
||||
});
|
||||
wrapper.unmount();
|
||||
});
|
||||
});
|
||||
|
||||
@ -14,10 +14,6 @@ describe('PageHeaderToolbar', () => {
|
||||
const onAboutClick = jest.fn();
|
||||
const onLogoutClick = jest.fn();
|
||||
|
||||
afterEach(() => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('expected content is rendered on initialization', async () => {
|
||||
await act(async () => {
|
||||
wrapper = mountWithContexts(
|
||||
|
||||
@ -8,9 +8,6 @@ jest.mock('../../api');
|
||||
let wrapper;
|
||||
|
||||
describe('<CopyButton/>', () => {
|
||||
afterEach(() => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
test('should mount properly', async () => {
|
||||
await act(async () => {
|
||||
wrapper = mountWithContexts(
|
||||
@ -24,6 +21,7 @@ describe('<CopyButton/>', () => {
|
||||
});
|
||||
expect(wrapper.find('CopyButton').length).toBe(1);
|
||||
});
|
||||
|
||||
test('should call the correct function on button click', async () => {
|
||||
const copyItem = jest.fn();
|
||||
await act(async () => {
|
||||
|
||||
@ -15,13 +15,6 @@ describe('<DataListToolbar />', () => {
|
||||
integerFields: ['page', 'page_size'],
|
||||
};
|
||||
|
||||
afterEach(() => {
|
||||
if (toolbar) {
|
||||
toolbar.unmount();
|
||||
toolbar = null;
|
||||
}
|
||||
});
|
||||
|
||||
const onSearch = jest.fn();
|
||||
const onReplaceSearch = jest.fn();
|
||||
const onSort = jest.fn();
|
||||
|
||||
@ -40,7 +40,6 @@ describe('<DisassociateButton />', () => {
|
||||
|
||||
afterAll(() => {
|
||||
jest.clearAllMocks();
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('should render button', () => {
|
||||
|
||||
@ -15,6 +15,5 @@ describe('<ExpandCollapse />', () => {
|
||||
/>
|
||||
);
|
||||
expect(wrapper.length).toBe(1);
|
||||
wrapper.unmount();
|
||||
});
|
||||
});
|
||||
|
||||
@ -6,10 +6,6 @@ import FieldWithPrompt from './FieldWithPrompt';
|
||||
describe('FieldWithPrompt', () => {
|
||||
let wrapper;
|
||||
|
||||
afterEach(() => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('Required asterisk and Popover hidden when not required and tooltip not provided', () => {
|
||||
wrapper = mountWithContexts(
|
||||
<Formik
|
||||
|
||||
@ -5,9 +5,6 @@ import JobListCancelButton from './JobListCancelButton';
|
||||
describe('<JobListCancelButton />', () => {
|
||||
let wrapper;
|
||||
|
||||
afterEach(() => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
test('should be disabled when no rows are selected', () => {
|
||||
wrapper = mountWithContexts(<JobListCancelButton jobsToCancel={[]} />);
|
||||
expect(wrapper.find('JobListCancelButton button').props().disabled).toBe(
|
||||
|
||||
@ -41,10 +41,6 @@ describe('<JobListItem />', () => {
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('initially renders successfully', () => {
|
||||
expect(wrapper.find('JobListItem').length).toBe(1);
|
||||
});
|
||||
@ -118,10 +114,6 @@ describe('<JobListItem with failed job />', () => {
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('launch button shown to users with launch capabilities', () => {
|
||||
expect(wrapper.find('LaunchButton').length).toBe(1);
|
||||
});
|
||||
|
||||
@ -24,7 +24,6 @@ describe('ListHeader', () => {
|
||||
/>
|
||||
);
|
||||
expect(wrapper.length).toBe(1);
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('should navigate when DataListToolbar calls onSort prop', async () => {
|
||||
|
||||
@ -36,7 +36,6 @@ describe('ApplicationLookup', () => {
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('should render successfully', async () => {
|
||||
|
||||
@ -38,7 +38,6 @@ describe('ExecutionEnvironmentLookup', () => {
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('should render successfully', async () => {
|
||||
|
||||
@ -26,7 +26,6 @@ describe('InventoryLookup', () => {
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('should render successfully and fetch data', async () => {
|
||||
|
||||
@ -122,7 +122,6 @@ describe('<Formik><MultiCredentialsLookup /></Formik>', () => {
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('should load credential types', async () => {
|
||||
|
||||
@ -12,7 +12,6 @@ describe('OrganizationLookup', () => {
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('should render successfully', async () => {
|
||||
|
||||
@ -21,10 +21,6 @@ describe('<NotificationListItem canToggleNotifications />', () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
if (wrapper) {
|
||||
wrapper.unmount();
|
||||
wrapper = null;
|
||||
}
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
|
||||
@ -40,8 +40,8 @@ describe('<ToolbarDeleteButton />', () => {
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('should render button', () => {
|
||||
wrapper = mountWithContexts(
|
||||
<ToolbarDeleteButton onDelete={() => {}} itemsToDelete={[]} />
|
||||
|
||||
@ -25,10 +25,6 @@ describe('PromptProjectDetail', () => {
|
||||
);
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('should render successfully', () => {
|
||||
expect(wrapper.find('PromptProjectDetail')).toHaveLength(1);
|
||||
});
|
||||
|
||||
@ -133,7 +133,6 @@ describe('<ResourceAccessList />', () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
wrapper.unmount();
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
|
||||
@ -113,12 +113,11 @@ describe('<Schedule />', () => {
|
||||
});
|
||||
await waitForElement(wrapper, 'ContentLoading', el => el.length === 0);
|
||||
});
|
||||
afterAll(() => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('renders successfully', async () => {
|
||||
expect(wrapper.length).toBe(1);
|
||||
});
|
||||
|
||||
test('expect all tabs to exist, including Back to Schedules', async () => {
|
||||
expect(
|
||||
wrapper.find('button[link="/templates/job_template/1/schedules"]').length
|
||||
|
||||
@ -52,10 +52,6 @@ describe('ScheduleList', () => {
|
||||
wrapper.update();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('should fetch schedules from api and render the list', () => {
|
||||
expect(loadSchedules).toHaveBeenCalled();
|
||||
expect(wrapper.find('ScheduleListItem').length).toBe(5);
|
||||
|
||||
@ -64,10 +64,6 @@ describe('ScheduleListItem', () => {
|
||||
);
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('Name correctly shown with correct link', () => {
|
||||
expect(
|
||||
wrapper
|
||||
@ -149,10 +145,6 @@ describe('ScheduleListItem', () => {
|
||||
);
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('Name correctly shown with correct link', () => {
|
||||
expect(
|
||||
wrapper
|
||||
@ -217,10 +209,6 @@ describe('ScheduleListItem', () => {
|
||||
);
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('should show missing resource icon', () => {
|
||||
expect(wrapper.find('ExclamationTriangleIcon').length).toBe(1);
|
||||
expect(wrapper.find('ScheduleToggle').prop('isDisabled')).toBe(true);
|
||||
|
||||
@ -15,15 +15,15 @@ describe('<ScheduleOccurrences>', () => {
|
||||
/>
|
||||
);
|
||||
});
|
||||
afterAll(() => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('Local option initially set', async () => {
|
||||
expect(wrapper.find('MultiButtonToggle').props().value).toBe('local');
|
||||
});
|
||||
|
||||
test('It renders the correct number of dates', async () => {
|
||||
expect(wrapper.find('dd').children().length).toBe(2);
|
||||
});
|
||||
|
||||
test('Clicking UTC button toggles the dates to utc', async () => {
|
||||
wrapper.find('button[aria-label="UTC"]').simulate('click');
|
||||
expect(wrapper.find('MultiButtonToggle').props().value).toBe('utc');
|
||||
@ -44,6 +44,7 @@ describe('<ScheduleOccurrences>', () => {
|
||||
).toBe('3/30/2020, 4:00:00 AM');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Only one date passed in', () => {
|
||||
test('Component should not render chldren', async () => {
|
||||
wrapper = mountWithContexts(
|
||||
@ -55,7 +56,6 @@ describe('<ScheduleOccurrences>', () => {
|
||||
/>
|
||||
);
|
||||
expect(wrapper.find('ScheduleOccurrences').children().length).toBe(0);
|
||||
wrapper.unmount();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -43,7 +43,6 @@ describe('<ScreenHeader />', () => {
|
||||
expect(breadcrumbItem.first().text()).toBe('Foo');
|
||||
expect(breadcrumbItem.last().text()).toBe('One');
|
||||
expect(breadcrumbHeading.text()).toBe('Bar');
|
||||
breadcrumbWrapper.unmount();
|
||||
});
|
||||
|
||||
test('renders breadcrumb items defined in breadcrumbConfig', () => {
|
||||
@ -66,7 +65,6 @@ describe('<ScreenHeader />', () => {
|
||||
expect(breadcrumbWrapper.find('BreadcrumbItem')).toHaveLength(
|
||||
crumbLength
|
||||
);
|
||||
breadcrumbWrapper.unmount();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -7,7 +7,6 @@ describe('<AdvancedSearch />', () => {
|
||||
let wrapper;
|
||||
|
||||
afterEach(() => {
|
||||
wrapper.unmount();
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
|
||||
@ -8,11 +8,10 @@ describe('<SelectableCard />', () => {
|
||||
test('initially renders without crashing when not selected', () => {
|
||||
wrapper = shallow(<SelectableCard onClick={onClick} />);
|
||||
expect(wrapper.length).toBe(1);
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('initially renders without crashing when selected', () => {
|
||||
wrapper = shallow(<SelectableCard isSelected onClick={onClick} />);
|
||||
expect(wrapper.length).toBe(1);
|
||||
wrapper.unmount();
|
||||
});
|
||||
});
|
||||
|
||||
@ -6,8 +6,8 @@ describe('<DraggableSelectedList />', () => {
|
||||
let wrapper;
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('should render expected rows', () => {
|
||||
const mockSelected = [
|
||||
{
|
||||
|
||||
@ -1,25 +1,17 @@
|
||||
import React from 'react';
|
||||
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
||||
|
||||
import ActivityStream from './ActivityStream';
|
||||
|
||||
jest.mock('react-router-dom', () => ({
|
||||
...jest.requireActual('react-router-dom'),
|
||||
}));
|
||||
jest.mock('../../api');
|
||||
|
||||
describe('<ActivityStream />', () => {
|
||||
let pageWrapper;
|
||||
|
||||
beforeEach(() => {
|
||||
pageWrapper = mountWithContexts(<ActivityStream />);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
pageWrapper.unmount();
|
||||
});
|
||||
|
||||
test('initially renders without crashing', () => {
|
||||
test('initially renders without crashing', async () => {
|
||||
let pageWrapper;
|
||||
await act(async () => {
|
||||
pageWrapper = await mountWithContexts(<ActivityStream />);
|
||||
});
|
||||
expect(pageWrapper.length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,21 +1,13 @@
|
||||
import React from 'react';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { createMemoryHistory } from 'history';
|
||||
import { shallow } from 'enzyme';
|
||||
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
||||
|
||||
import Applications from './Applications';
|
||||
|
||||
jest.mock('react-router-dom', () => ({
|
||||
...jest.requireActual('react-router-dom'),
|
||||
}));
|
||||
|
||||
describe('<Applications />', () => {
|
||||
let wrapper;
|
||||
|
||||
afterEach(() => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('renders successfully', () => {
|
||||
wrapper = mountWithContexts(<Applications />);
|
||||
const pageSections = wrapper.find('PageSection');
|
||||
@ -28,22 +20,20 @@ describe('<Applications />', () => {
|
||||
const history = createMemoryHistory({
|
||||
initialEntries: ['/applications/add'],
|
||||
});
|
||||
wrapper = mountWithContexts(<Applications />, {
|
||||
wrapper = shallow(<Applications />, {
|
||||
context: { router: { history } },
|
||||
});
|
||||
expect(wrapper.find('Modal[title="Application information"]').length).toBe(
|
||||
0
|
||||
);
|
||||
await act(async () => {
|
||||
wrapper
|
||||
.find('ApplicationAdd')
|
||||
.props()
|
||||
.onSuccessfulAdd({
|
||||
name: 'test',
|
||||
client_id: 'foobar',
|
||||
client_secret: 'aaaaaaaaaaaaaaaaaaaaaaaaaa',
|
||||
});
|
||||
});
|
||||
wrapper
|
||||
.find('ApplicationAdd')
|
||||
.props()
|
||||
.onSuccessfulAdd({
|
||||
name: 'test',
|
||||
client_id: 'foobar',
|
||||
client_secret: 'aaaaaaaaaaaaaaaaaaaaaaaaaa',
|
||||
});
|
||||
wrapper.update();
|
||||
expect(wrapper.find('Modal[title="Application information"]').length).toBe(
|
||||
1
|
||||
|
||||
@ -196,7 +196,6 @@ describe('<CredentialAdd />', () => {
|
||||
});
|
||||
wrapper.update();
|
||||
expect(wrapper.find('ContentError').length).toBe(1);
|
||||
wrapper.unmount();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -485,7 +485,6 @@ describe('<CredentialEdit />', () => {
|
||||
});
|
||||
wrapper.update();
|
||||
expect(wrapper.find('ContentError').length).toBe(1);
|
||||
wrapper.unmount();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -33,7 +33,6 @@ describe('<CredentialList />', () => {
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('initially renders successfully', () => {
|
||||
|
||||
@ -10,10 +10,6 @@ jest.mock('../../../api');
|
||||
describe('<CredentialListItem />', () => {
|
||||
let wrapper;
|
||||
|
||||
afterEach(() => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('edit button shown to users with edit capabilities', () => {
|
||||
wrapper = mountWithContexts(
|
||||
<table>
|
||||
|
||||
@ -1,60 +1,16 @@
|
||||
import React from 'react';
|
||||
import { createMemoryHistory } from 'history';
|
||||
import { mountWithContexts } from '../../../testUtils/enzymeHelpers';
|
||||
import { shallow } from 'enzyme';
|
||||
import Credentials from './Credentials';
|
||||
|
||||
jest.mock('react-router-dom', () => ({
|
||||
...jest.requireActual('react-router-dom'),
|
||||
}));
|
||||
|
||||
describe('<Credentials />', () => {
|
||||
let wrapper;
|
||||
test('should set breadcrumb config', () => {
|
||||
const wrapper = shallow(<Credentials />);
|
||||
|
||||
afterEach(() => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('initially renders successfully', () => {
|
||||
wrapper = mountWithContexts(<Credentials />);
|
||||
});
|
||||
|
||||
test('should display credential list breadcrumb heading', () => {
|
||||
const history = createMemoryHistory({
|
||||
initialEntries: ['/credentials'],
|
||||
const header = wrapper.find('ScreenHeader');
|
||||
expect(header.prop('streamType')).toEqual('credential');
|
||||
expect(header.prop('breadcrumbConfig')).toEqual({
|
||||
'/credentials': 'Credentials',
|
||||
'/credentials/add': 'Create New Credential',
|
||||
});
|
||||
|
||||
wrapper = mountWithContexts(<Credentials />, {
|
||||
context: {
|
||||
router: {
|
||||
history,
|
||||
route: {
|
||||
location: history.location,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(wrapper.find('Crumb').length).toBe(0);
|
||||
expect(wrapper.find('Title').text()).toBe('Credentials');
|
||||
});
|
||||
|
||||
test('should display create new credential breadcrumb heading', () => {
|
||||
const history = createMemoryHistory({
|
||||
initialEntries: ['/credentials/add'],
|
||||
});
|
||||
|
||||
wrapper = mountWithContexts(<Credentials />, {
|
||||
context: {
|
||||
router: {
|
||||
history,
|
||||
route: {
|
||||
location: history.location,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(wrapper.find('Crumb').length).toBe(2);
|
||||
expect(wrapper.find('Title').text()).toBe('Create New Credential');
|
||||
});
|
||||
});
|
||||
|
||||
@ -95,15 +95,15 @@ describe('<CredentialForm />', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
afterAll(() => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('should display form fields on add properly', async () => {
|
||||
addFieldExpects();
|
||||
});
|
||||
|
||||
test('should hide Test button initially', () => {
|
||||
expect(wrapper.find('Button[children="Test"]').length).toBe(0);
|
||||
});
|
||||
|
||||
test('should update form values', async () => {
|
||||
// name and description change
|
||||
await act(async () => {
|
||||
@ -135,6 +135,7 @@ describe('<CredentialForm />', () => {
|
||||
name: 'organization',
|
||||
});
|
||||
});
|
||||
|
||||
test('should display cred type subform when scm type select has a value', async () => {
|
||||
await act(async () => {
|
||||
await wrapper
|
||||
@ -218,6 +219,7 @@ describe('<CredentialForm />', () => {
|
||||
wrapper.find('textarea#credential-ssh_key_data').prop('value')
|
||||
).toBe('');
|
||||
});
|
||||
|
||||
test('should update field when RSA Private Key file uploaded', async () => {
|
||||
await act(async () => {
|
||||
wrapper.find('FileUpload#credential-ssh_key_data').invoke('onChange')(
|
||||
@ -232,6 +234,7 @@ describe('<CredentialForm />', () => {
|
||||
'-----BEGIN PRIVATE KEY-----\\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\\n-----END PRIVATE KEY-----\\n'
|
||||
);
|
||||
});
|
||||
|
||||
test('should show error when error thrown parsing JSON', async () => {
|
||||
await act(async () => {
|
||||
await wrapper
|
||||
@ -295,9 +298,6 @@ describe('<CredentialForm />', () => {
|
||||
});
|
||||
|
||||
describe('Edit', () => {
|
||||
afterEach(() => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
test('Initially renders successfully', async () => {
|
||||
await act(async () => {
|
||||
wrapper = mountWithContexts(
|
||||
|
||||
@ -15,9 +15,6 @@ const fieldOptions = {
|
||||
|
||||
describe('<CredentialField />', () => {
|
||||
let wrapper;
|
||||
afterEach(() => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
test('renders correctly without initial value', () => {
|
||||
wrapper = mountWithContexts(
|
||||
<Formik
|
||||
@ -42,6 +39,7 @@ describe('<CredentialField />', () => {
|
||||
expect(wrapper.find('KeyIcon').length).toBe(1);
|
||||
expect(wrapper.find('PficonHistoryIcon').length).toBe(0);
|
||||
});
|
||||
|
||||
test('renders correctly with initial value', () => {
|
||||
wrapper = mountWithContexts(
|
||||
<Formik
|
||||
@ -68,6 +66,7 @@ describe('<CredentialField />', () => {
|
||||
expect(wrapper.find('KeyIcon').length).toBe(1);
|
||||
expect(wrapper.find('PficonHistoryIcon').length).toBe(1);
|
||||
});
|
||||
|
||||
test('replace/revert button behaves as expected', async () => {
|
||||
wrapper = mountWithContexts(
|
||||
<Formik
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import { Formik } from 'formik';
|
||||
import { TextInput } from '@patternfly/react-core';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { mountWithContexts } from '../../../../../testUtils/enzymeHelpers';
|
||||
import CredentialPluginField from './CredentialPluginField';
|
||||
|
||||
@ -10,6 +11,8 @@ const fieldOptions = {
|
||||
type: 'string',
|
||||
};
|
||||
|
||||
jest.mock('../../../../api');
|
||||
|
||||
describe('<CredentialPluginField />', () => {
|
||||
let wrapper;
|
||||
describe('No plugin configured', () => {
|
||||
@ -34,20 +37,23 @@ describe('<CredentialPluginField />', () => {
|
||||
</Formik>
|
||||
);
|
||||
});
|
||||
afterAll(() => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('renders the expected content', () => {
|
||||
expect(wrapper.find('input').length).toBe(1);
|
||||
expect(wrapper.find('KeyIcon').length).toBe(1);
|
||||
expect(wrapper.find('CredentialPluginSelected').length).toBe(0);
|
||||
});
|
||||
test('clicking plugin button shows plugin prompt', () => {
|
||||
|
||||
test('clicking plugin button shows plugin prompt', async () => {
|
||||
expect(wrapper.find('CredentialPluginPrompt').length).toBe(0);
|
||||
wrapper.find('KeyIcon').simulate('click');
|
||||
await act(async () => {
|
||||
wrapper.find('KeyIcon').simulate('click');
|
||||
});
|
||||
wrapper.update();
|
||||
expect(wrapper.find('CredentialPluginPrompt').length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Plugin already configured', () => {
|
||||
beforeAll(() => {
|
||||
wrapper = mountWithContexts(
|
||||
@ -78,9 +84,7 @@ describe('<CredentialPluginField />', () => {
|
||||
</Formik>
|
||||
);
|
||||
});
|
||||
afterAll(() => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('renders the expected content', () => {
|
||||
expect(wrapper.find('CredentialPluginPrompt').length).toBe(0);
|
||||
expect(wrapper.find('input').length).toBe(0);
|
||||
|
||||
@ -99,10 +99,6 @@ describe('<CredentialPluginPrompt />', () => {
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('should render Wizard with all steps', async () => {
|
||||
const wizard = await waitForElement(wrapper, 'Wizard');
|
||||
const steps = wizard.prop('steps');
|
||||
@ -119,15 +115,18 @@ describe('<CredentialPluginPrompt />', () => {
|
||||
wrapper.find('Radio').filterWhere(radio => radio.isChecked).length
|
||||
).toBe(0);
|
||||
});
|
||||
|
||||
test('next button disabled until credential selected', () => {
|
||||
expect(wrapper.find('Button[children="Next"]').prop('isDisabled')).toBe(
|
||||
true
|
||||
);
|
||||
});
|
||||
|
||||
test('clicking cancel button calls correct function', () => {
|
||||
wrapper.find('Button[children="Cancel"]').simulate('click');
|
||||
expect(onClose).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('clicking credential row enables next button', async () => {
|
||||
await waitForElement(wrapper, 'CheckboxListItem', el => el.length > 0);
|
||||
await act(async () => {
|
||||
@ -207,9 +206,7 @@ describe('<CredentialPluginPrompt />', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
afterAll(() => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('should render Wizard with all steps', async () => {
|
||||
const wizard = await waitForElement(wrapper, 'Wizard');
|
||||
const steps = wizard.prop('steps');
|
||||
@ -218,6 +215,7 @@ describe('<CredentialPluginPrompt />', () => {
|
||||
expect(steps[0].name).toEqual('Credential');
|
||||
expect(steps[1].name).toEqual('Metadata');
|
||||
});
|
||||
|
||||
test('credentials step renders correctly', async () => {
|
||||
await waitForElement(wrapper, 'CheckboxListItem', el => el.length > 0);
|
||||
|
||||
@ -233,6 +231,7 @@ describe('<CredentialPluginPrompt />', () => {
|
||||
false
|
||||
);
|
||||
});
|
||||
|
||||
test('metadata step renders correctly', async () => {
|
||||
await act(async () => {
|
||||
wrapper.find('Button[children="Next"]').simulate('click');
|
||||
@ -247,6 +246,7 @@ describe('<CredentialPluginPrompt />', () => {
|
||||
wrapper.find('input#credential-secret_version').prop('value')
|
||||
).toBe('9000');
|
||||
});
|
||||
|
||||
test('clicking Test button makes correct call', async () => {
|
||||
await act(async () => {
|
||||
wrapper.find('Button[children="Test"]').simulate('click');
|
||||
|
||||
@ -16,17 +16,17 @@ describe('<CredentialPluginSelected />', () => {
|
||||
/>
|
||||
);
|
||||
});
|
||||
afterAll(() => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
test('renders the expected content', () => {
|
||||
expect(wrapper.find('CredentialChip').length).toBe(1);
|
||||
expect(wrapper.find('KeyIcon').length).toBe(1);
|
||||
});
|
||||
|
||||
test('clearing plugin calls expected function', () => {
|
||||
wrapper.find('CredentialChip button').simulate('click');
|
||||
expect(onClearPlugin).toBeCalledTimes(1);
|
||||
});
|
||||
|
||||
test('editing plugin calls expected function', () => {
|
||||
wrapper.find('KeyIcon').simulate('click');
|
||||
expect(onEditPlugin).toBeCalledTimes(1);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user