grafana/public/test/helpers/selectOptionInTest.ts
Jack Westbrook ccd75d72f8
Chore: Remove react-testing-lib from bundles (#50442)
* refactor(selectoptiontest): move helper function out of grafana/ui so testing-lib isn't in bundle

* test(selectoptionintest): update import location of helper function

* test(amroutes): put back missing selectOptionInTest helper

* test(selectoptionintest): clean up remaining file imports / exports

* test(queryeditor): fix failing import

* refactor(grafana-ui): reuse selectOptionInTest in SelectBase test
2022-06-09 11:10:48 +02:00

12 lines
519 B
TypeScript

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 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;