grafana/public/test/helpers/selectOptionInTest.ts
renovate[bot] 909d0f4ced
Update Monthly patch updates (#58002)
* Update Monthly patch updates

* update typescript sdk, add ignore for emotion css prop

* fix unit tests

* type fixes

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
2022-11-02 12:05:32 +00:00

13 lines
584 B
TypeScript

import { waitFor } from '@testing-library/react';
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>
) => await waitFor(() => select(input, optionOrOptions, { container: document.body }));
// 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;