Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const select = async (
input: HTMLElement,
optionOrOptions: string | RegExp | Array,
config: Config = {}
) => {
const options = Array.isArray(optionOrOptions)
? optionOrOptions
: [optionOrOptions];
const container = config.container || getReactSelectContainerFromInput(input);
// Select the items we care about
for (const option of options) {
focus(input);
// only consider accessible elements
const optionElement = await findByText(container, option, {
// @ts-ignore invalid rtl types :'(
ignore: ":not([tabindex])"
});
fireEvent.click(optionElement);
}
};
export const waitForText = async (text, container = document) => findByText(container, text);
export const create = async (
input: HTMLElement,
option: string,
config: CreateConfig = {}
) => {
const createOptionText = config.createOptionText || /^Create "/;
focus(input);
type(input, option);
fireEvent.change(input, { target: { value: option } });
await select(input, createOptionText, config);
await findByText(getReactSelectContainerFromInput(input), option);
};
export const waitForTabToOpen = (fileName) =>
findByText(document.querySelector('.multi-file-edit-pane'), fileName);