Adding some propType fixes to `TextFieldBase` (#16508)

* Adding some propType fixes

* lint fixes
feature/default_network_editable
George Marshall 2 years ago committed by GitHub
parent 6907c4a565
commit be5d70623e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      ui/components/component-library/text-field-base/text-field-base.js
  2. 14
      ui/components/component-library/text-field-base/text-field-base.test.js

@ -155,7 +155,7 @@ TextFieldBase.propTypes = {
/** /**
* Autocomplete allows the browser to predict the value based on earlier typed values * Autocomplete allows the browser to predict the value based on earlier typed values
*/ */
autoComplete: PropTypes.string, autoComplete: PropTypes.bool,
/** /**
* If `true`, the input will be focused during the first mount. * If `true`, the input will be focused during the first mount.
*/ */

@ -2,9 +2,10 @@
import React from 'react'; import React from 'react';
import { fireEvent, render } from '@testing-library/react'; import { fireEvent, render } from '@testing-library/react';
import userEvent from '@testing-library/user-event'; import userEvent from '@testing-library/user-event';
import { SIZES } from '../../../helpers/constants/design-system'; import { SIZES } from '../../../helpers/constants/design-system';
import Box from '../../ui/box';
import { TextFieldBase } from './text-field-base'; import { TextFieldBase } from './text-field-base';
describe('TextFieldBase', () => { describe('TextFieldBase', () => {
@ -188,11 +189,7 @@ describe('TextFieldBase', () => {
}); });
it('should render with error className when error is true', () => { it('should render with error className when error is true', () => {
const { getByTestId } = render( const { getByTestId } = render(
<TextFieldBase <TextFieldBase error data-testid="text-field-base-error" />,
error
value="error value"
data-testid="text-field-base-error"
/>,
); );
expect(getByTestId('text-field-base-error')).toHaveClass( expect(getByTestId('text-field-base-error')).toHaveClass(
'mm-text-field-base--error', 'mm-text-field-base--error',
@ -236,7 +233,10 @@ describe('TextFieldBase', () => {
); );
}); });
it('should render with a custom input and still work', () => { it('should render with a custom input and still work', () => {
const CustomInputComponent = (props) => <input {...props} />; const CustomInputComponent = React.forwardRef((props, ref) => (
<Box ref={ref} as="input" {...props} />
));
CustomInputComponent.displayName = 'CustomInputComponent'; // fixes eslint error
const { getByTestId } = render( const { getByTestId } = render(
<TextFieldBase <TextFieldBase
InputComponent={CustomInputComponent} InputComponent={CustomInputComponent}

Loading…
Cancel
Save