How to use the @testing-library/dom.fireEvent.mouseDown function in @testing-library/dom

To help you get started, we’ve selected a few @testing-library/dom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github romgain / react-select-event / src / index.ts View on Github external
const clear = async (input: HTMLElement, clearButton: Element) => {
  fireEvent.mouseDown(clearButton);
  fireEvent.click(clearButton);
  // react-select will prevent the menu from opening, and asynchronously focus the select field...
  await wait();
  input.blur();
};
github testing-library / user-event / src / index.js View on Github external
function selectOption(select, option) {
  fireEvent.mouseOver(option);
  fireEvent.mouseMove(option);
  fireEvent.mouseDown(option);
  fireEvent.focus(option);
  fireEvent.mouseUp(option);
  fireEvent.click(option);

  option.selected = true;

  fireEvent.change(select);
}
github testing-library / user-event / src / index.js View on Github external
function clickLabel(label) {
  fireEvent.mouseOver(label);
  fireEvent.mouseMove(label);
  fireEvent.mouseDown(label);
  fireEvent.mouseUp(label);

  if (label.htmlFor) {
    const input = document.getElementById(label.htmlFor);
    input.focus();
    fireEvent.click(label);
  } else {
    const input = label.querySelector("input,textarea,select");
    input.focus();
    label.focus();
    fireEvent.click(label);
  }
}
github testing-library / user-event / src / index.js View on Github external
function dblClickCheckbox(checkbox) {
  fireEvent.mouseOver(checkbox);
  fireEvent.mouseMove(checkbox);
  fireEvent.mouseDown(checkbox);
  fireEvent.focus(checkbox);
  fireEvent.mouseUp(checkbox);
  fireEvent.click(checkbox);
  fireEvent.mouseDown(checkbox);
  fireEvent.mouseUp(checkbox);
  fireEvent.click(checkbox);
}