How to use the react-testing-library.fireEvent.mouseDown function in react-testing-library

To help you get started, we’ve selected a few react-testing-library 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 bmcmahen / react-gesture-responder / src / __tests__ / responder.tsx View on Github external
const { getByTestId } = render(
    
  );

  const child = getByTestId("example");

  // mouse events
  fireEvent.mouseDown(child);
  expect(onGrant).toBeCalled();
  fireEvent.mouseMove(child);
  expect(onMove).toBeCalled();
  fireEvent.mouseUp(child);
  expect(onRelease).toBeCalled();

  // touch events
  fireEvent.touchStart(child);
  fireEvent.touchMove(child);
  fireEvent.touchEnd(child);
  expect(onGrant).toBeCalledTimes(2);
  expect(onMove).toBeCalledTimes(4);
  expect(onRelease).toBeCalledTimes(2);
});
github flow-typed / flow-typed / definitions / npm / react-testing-library_v5.x.x / flow_v0.67.1- / test_react-testing-library_v5.x.x.js View on Github external
fireEvent.input(htmlEl);
    fireEvent.invalid(htmlEl);
    fireEvent.submit(htmlEl);
    fireEvent.click(htmlEl);
    fireEvent.contextMenu(htmlEl);
    fireEvent.dblClick(htmlEl);
    fireEvent.doubleClick(htmlEl);
    fireEvent.drag(htmlEl);
    fireEvent.dragEnd(htmlEl);
    fireEvent.dragEnter(htmlEl);
    fireEvent.dragExit(htmlEl);
    fireEvent.dragLeave(htmlEl);
    fireEvent.dragOver(htmlEl);
    fireEvent.dragStart(htmlEl);
    fireEvent.drop(htmlEl);
    fireEvent.mouseDown(htmlEl);
    fireEvent.mouseEnter(htmlEl);
    fireEvent.mouseLeave(htmlEl);
    fireEvent.mouseMove(htmlEl);
    fireEvent.mouseOut(htmlEl);
    fireEvent.mouseOver(htmlEl);
    fireEvent.mouseUp(htmlEl);
    fireEvent.select(htmlEl);
    fireEvent.touchCancel(htmlEl);
    fireEvent.touchEnd(htmlEl);
    fireEvent.touchMove(htmlEl);
    fireEvent.touchStart(htmlEl);
    fireEvent.scroll(htmlEl);
    fireEvent.wheel(htmlEl);
    fireEvent.abort(htmlEl);
    fireEvent.canPlay(htmlEl);
    fireEvent.canPlayThrough(htmlEl);
github whizkydee / dropd / packages / react-dropd / __tests__ / index.js View on Github external
test('should close on click away when `closeOnBlur` prop is set to true', () => {
    const { button, baseElement, list } = mockDropd({ closeOnBlur: true })

    fireEvent.mouseDown(button)
    fireEvent.mouseDown(baseElement)
    expect(list.classList.contains('open')).toBeFalsy()
  })
github framer / motion / src / events / __tests__ / use-event.tests.tsx View on Github external
it("should call the handler when the event is fired", () => {
        const handler = jest.fn()
        const Component = () => {
            const ref = useRef(null)
            useEvent("mousedown", ref, handler)
            return <div>
        }
        const { container, rerender } = render()
        rerender()
        fireEvent.mouseDown(container.firstChild as Element)
        expect(handler).toHaveBeenCalledTimes(1)
    })
</div>
github ticketmaster / aurora / src / components / Input / __tests__ / DropDownGroup.spec.js View on Github external
it("Should not focus onClick", () => {
    const { container } = renderTestComponentOne({ disabled: true });
    fireEvent.mouseDown(container.querySelector("label"));
    expect(container.firstChild).toMatchSnapshot();
  });
github whizkydee / dropd / packages / react-dropd / __tests__ / index.js View on Github external
test('should not close on input mousedown when `closeOnBlur` prop is set to false', () => {
    const { button, baseElement, list, inputMock } = mockDropd({
      closeOnBlur: false,
    })

    fireEvent.mouseDown(button)
    fireEvent.mouseDown(inputMock)
    expect(document.activeElement).toBe(baseElement)
    expect(list.classList.contains('open')).toBeTruthy()
  })
github whizkydee / dropd / packages / react-dropd / __tests__ / index.js View on Github external
test('should call the `onOpen` function when it is passed', () => {
    const mockFn = jest.fn()

    fireEvent.mouseDown(mockDropd({ onOpen: mockFn }).button)
    expect(mockFn).toHaveBeenCalledTimes(1)
  })
github whizkydee / dropd / packages / react-dropd / __tests__ / index.js View on Github external
test('should call the `onItemChange` function when it is passed', () => {
    const mockFn = jest.fn()

    fireEvent.mouseDown(mockDropd({ onItemChange: mockFn }).items[0])
    expect(mockFn).toHaveBeenCalledTimes(1)
  })
})
github bmcmahen / react-gesture-responder / src / __tests__ / responder.tsx View on Github external
onStartShouldSet: () =&gt; true,
          onMoveShouldSet: () =&gt; {
            return true;
          },
          onGrant,
          onTerminate: otherTerminate
        }}
      /&gt;
    
  );

  const child = getByTestId("release");
  fireEvent.mouseDown(child);

  const other = getByTestId("other");
  fireEvent.mouseDown(other);
  fireEvent.mouseMove(other);

  expect(onGrant).toBeCalled();
  expect(otherTerminate).toBeCalledTimes(0);
});
github framer / motion / src / events / __tests__ / use-event.tests.tsx View on Github external
const promise = new Promise(resolve =&gt; {
            const Component = () =&gt; {
                const ref = useRef(document.body)
                useEvent("mousedown", ref, handler)
                useEffect(resolve)
                return <div>
            }
            const { rerender, unmount } = render()
            rerender()
            unmount()
            fireEvent.mouseDown(document.body)
        })
        await expect(promise).resolves.toEqual(undefined)</div>