delete unused/redundant component

This commit is contained in:
Keith Grant 2020-01-30 10:55:50 -08:00
parent 0ef7ef22eb
commit 67d8c1a4b5
2 changed files with 0 additions and 132 deletions

View File

@ -1,74 +0,0 @@
import React from 'react';
import { func, shape } from 'prop-types';
import { Formik } from 'formik';
import { withI18n } from '@lingui/react';
import { t } from '@lingui/macro';
import { Form } from '@patternfly/react-core';
import FormRow from '@components/FormRow';
import FormField from '@components/FormField';
import FormActionGroup from '@components/FormActionGroup/FormActionGroup';
import { VariablesField } from '@components/CodeMirrorInput';
import { required } from '@util/validators';
function InventoryHostForm({ handleSubmit, handleCancel, host, i18n }) {
return (
<Formik
initialValues={{
name: host.name,
description: host.description,
variables: host.variables,
}}
onSubmit={handleSubmit}
>
{formik => (
<Form autoComplete="off" onSubmit={formik.handleSubmit}>
<FormRow>
<FormField
id="host-name"
name="name"
type="text"
label={i18n._(t`Name`)}
validate={required(null, i18n)}
isRequired
/>
<FormField
id="host-description"
name="description"
type="text"
label={i18n._(t`Description`)}
/>
</FormRow>
<FormRow>
<VariablesField
id="host-variables"
name="variables"
label={i18n._(t`Variables`)}
/>
</FormRow>
<FormActionGroup
onCancel={handleCancel}
onSubmit={() => {
formik.handleSubmit();
}}
/>
</Form>
)}
</Formik>
);
}
InventoryHostForm.propTypes = {
handleSubmit: func.isRequired,
handleCancel: func.isRequired,
host: shape({}),
};
InventoryHostForm.defaultProps = {
host: {
name: '',
description: '',
variables: '---\n',
},
};
export default withI18n()(InventoryHostForm);

View File

@ -1,58 +0,0 @@
import React from 'react';
import { act } from 'react-dom/test-utils';
import { mountWithContexts } from '@testUtils/enzymeHelpers';
import { sleep } from '@testUtils/testUtils';
import InventoryHostForm from './InventoryHostForm';
jest.mock('@api');
describe('<InventoryHostform />', () => {
let wrapper;
const handleSubmit = jest.fn();
const handleCancel = jest.fn();
const mockHostData = {
name: 'foo',
description: 'bar',
inventory: 1,
variables: '---\nfoo: bar',
};
beforeEach(async () => {
await act(async () => {
wrapper = mountWithContexts(
<InventoryHostForm
handleCancel={handleCancel}
handleSubmit={handleSubmit}
host={mockHostData}
/>
);
});
});
afterEach(() => {
wrapper.unmount();
});
test('should display form fields', () => {
expect(wrapper.find('FormGroup[label="Name"]').length).toBe(1);
expect(wrapper.find('FormGroup[label="Description"]').length).toBe(1);
expect(wrapper.find('VariablesField').length).toBe(1);
});
test('should call handleSubmit when Submit button is clicked', async () => {
expect(handleSubmit).not.toHaveBeenCalled();
await act(async () => {
wrapper.find('button[aria-label="Save"]').simulate('click');
});
expect(handleSubmit).toHaveBeenCalled();
});
test('should call handleCancel when Cancel button is clicked', async () => {
expect(handleCancel).not.toHaveBeenCalled();
wrapper.find('button[aria-label="Cancel"]').simulate('click');
await sleep(1);
expect(handleCancel).toHaveBeenCalled();
});
});