2022-11-02 20:05:32 +08:00
|
|
|
import { waitFor } from '@testing-library/react';
|
2021-07-14 21:04:23 +08:00
|
|
|
import { select } from 'react-select-event';
|
|
|
|
|
|
|
|
// Used to select an option or options from a Select in unit tests
|
|
|
|
export const selectOptionInTest = async (
|
|
|
|
input: HTMLElement,
|
|
|
|
optionOrOptions: string | RegExp | Array<string | RegExp>
|
2022-11-02 20:05:32 +08:00
|
|
|
) => await waitFor(() => select(input, optionOrOptions, { container: document.body }));
|
2021-11-01 19:06:28 +08:00
|
|
|
|
|
|
|
// Finds the parent of the Select so you can assert if it has a value
|
|
|
|
export const getSelectParent = (input: HTMLElement) =>
|
|
|
|
input.parentElement?.parentElement?.parentElement?.parentElement?.parentElement;
|