diff --git a/src/__tests__/events.js b/src/__tests__/events.js index bac063de..bc36dab3 100644 --- a/src/__tests__/events.js +++ b/src/__tests__/events.js @@ -197,6 +197,26 @@ test('onChange works', () => { expect(handleChange).toHaveBeenCalledTimes(1) }) +test('calling `onPointerEnter` directly works too', () => { + const handlePointerEnter = jest.fn() + const handlePointerLeave = jest.fn() + const {container} = render( +
+
, + ) + const button = container.firstChild.firstChild + + fireEvent.pointerEnter(button) + expect(handlePointerEnter).toHaveBeenCalledTimes(1) + + fireEvent.pointerLeave(button) + expect(handlePointerLeave).toHaveBeenCalledTimes(1) +}) + test('calling `fireEvent` directly works too', () => { const handleEvent = jest.fn() const { diff --git a/src/fire-event.js b/src/fire-event.js index b4e60928..cb790c7f 100644 --- a/src/fire-event.js +++ b/src/fire-event.js @@ -24,6 +24,17 @@ fireEvent.mouseLeave = (...args) => { return fireEvent.mouseOut(...args) } +const pointerEnter = fireEvent.pointerEnter +const pointerLeave = fireEvent.pointerLeave +fireEvent.pointerEnter = (...args) => { + pointerEnter(...args) + return fireEvent.pointerOver(...args) +} +fireEvent.pointerLeave = (...args) => { + pointerLeave(...args) + return fireEvent.pointerOut(...args) +} + const select = fireEvent.select fireEvent.select = (node, init) => { select(node, init)