1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00

Fixing FormTextField props and test (#17939)

This commit is contained in:
George Marshall 2023-03-06 15:45:23 -08:00 committed by GitHub
parent c8e8db2666
commit abff49561d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
/* eslint-disable jest/require-top-level-describe */
import React from 'react';
import PropTypes from 'prop-types';
import { fireEvent, render } from '@testing-library/react';
import { renderWithUserEvent } from '../../../../test/lib/render-helpers';
@ -227,9 +228,19 @@ describe('TextField', () => {
expect(getByTestId('text-field-required')).toHaveAttribute('required', '');
});
it('should render with a custom input and still work', async () => {
const CustomInputComponent = React.forwardRef((props, ref) => (
<Box ref={ref} as="input" {...props} />
));
const CustomInputComponent = React.forwardRef(
({ disableStateStyles, ...props }, ref) => (
<Box
ref={ref}
as="input"
{...props}
placeholder={`Removing ${disableStateStyles} from ...props spread to prevent error in test`}
/>
),
);
CustomInputComponent.propTypes = {
disableStateStyles: PropTypes.bool,
};
CustomInputComponent.displayName = 'CustomInputComponent'; // fixes eslint error
const { getByTestId, user } = renderWithUserEvent(
<TextField