Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing FormTextField test #17939

Merged
merged 1 commit into from
Mar 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions ui/components/component-library/text-field/text-field.test.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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
Expand Down