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

test: Clean up SelectAsyncControl test warnings #22969

Merged
merged 1 commit into from
Feb 15, 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
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ beforeEach(() => {
jest.resetAllMocks();
});

test('Should render', () => {
test('Should render', async () => {
const props = createProps();
render(<SelectAsyncControl {...props} />, { useRedux: true });
expect(screen.getByTestId('select-test')).toBeInTheDocument();
expect(await screen.findByTestId('select-test')).toBeInTheDocument();
});

test('Should send correct props to Select component - value props', () => {
test('Should send correct props to Select component - value props', async () => {
const props = createProps();
render(<SelectAsyncControl {...props} />, { useRedux: true });

expect(screen.getByTestId('select-test')).toHaveAttribute(
expect(await screen.findByTestId('select-test')).toHaveAttribute(
'data-value',
JSON.stringify(props.value),
);
Expand All @@ -89,20 +89,20 @@ test('Should send correct props to Select component - value props', () => {
);
});

test('Should send correct props to Select component - function onChange multi:true', () => {
test('Should send correct props to Select component - function onChange multi:true', async () => {
const props = createProps();
render(<SelectAsyncControl {...props} />, { useRedux: true });
expect(props.onChange).toBeCalledTimes(0);
userEvent.click(screen.getByText('onChange'));
userEvent.click(await screen.findByText('onChange'));
expect(props.onChange).toBeCalledTimes(1);
});

test('Should send correct props to Select component - function onChange multi:false', () => {
test('Should send correct props to Select component - function onChange multi:false', async () => {
const props = createProps();
render(<SelectAsyncControl {...{ ...props, multi: false }} />, {
useRedux: true,
});
expect(props.onChange).toBeCalledTimes(0);
userEvent.click(screen.getByText('onChange'));
userEvent.click(await screen.findByText('onChange'));
expect(props.onChange).toBeCalledTimes(1);
});