Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
}
}
function clickElement(element) {
fireEvent.mouseOver(element);
fireEvent.mouseMove(element);
fireEvent.mouseDown(element);
element.focus();
fireEvent.mouseUp(element);
fireEvent.click(element);
const labelAncestor = findTagInParents(element, "LABEL");
labelAncestor && clickLabel(labelAncestor);
}
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);
}
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);
}
function clickBooleanElement(element) {
if (element.disabled) return;
fireEvent.mouseOver(element);
fireEvent.mouseMove(element);
fireEvent.mouseDown(element);
fireEvent.focus(element);
fireEvent.mouseUp(element);
fireEvent.click(element);
}
function dblClickElement(element) {
fireEvent.mouseOver(element);
fireEvent.mouseMove(element);
fireEvent.mouseDown(element);
element.focus();
fireEvent.mouseUp(element);
fireEvent.click(element);
fireEvent.mouseDown(element);
fireEvent.mouseUp(element);
fireEvent.click(element);
fireEvent.dblClick(element);
const labelAncestor = findTagInParents(element, "LABEL");
labelAncestor && clickLabel(labelAncestor);
}
function dblClickElement(element) {
fireEvent.mouseOver(element);
fireEvent.mouseMove(element);
fireEvent.mouseDown(element);
element.focus();
fireEvent.mouseUp(element);
fireEvent.click(element);
fireEvent.mouseDown(element);
fireEvent.mouseUp(element);
fireEvent.click(element);
fireEvent.dblClick(element);
const labelAncestor = findTagInParents(element, "LABEL");
labelAncestor && clickLabel(labelAncestor);
}
act(() => {
fireEvent.mouseUp(element)
})