Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Trigger ongot-/onlostpointercapture when calling got-/lostpointercapture #786

Merged
merged 5 commits into from Sep 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -44,7 +44,7 @@
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.11.2",
"@testing-library/dom": "^7.23.0"
"@testing-library/dom": "^7.24.2"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.11.4",
Expand Down
36 changes: 16 additions & 20 deletions src/__tests__/events.js
Expand Up @@ -62,6 +62,22 @@ const eventTypes = [
],
elementType: 'button',
},
{
type: 'Pointer',
events: [
'pointerOver',
'pointerEnter',
'pointerDown',
'pointerMove',
'pointerUp',
'pointerCancel',
'pointerOut',
'pointerLeave',
'gotPointerCapture',
'lostPointerCapture',
],
elementType: 'button',
},
{
type: 'Selection',
events: ['select'],
Expand Down Expand Up @@ -197,26 +213,6 @@ test('onChange works', () => {
expect(handleChange).toHaveBeenCalledTimes(1)
})

test('calling `onPointerEnter` directly works too', () => {
const handlePointerEnter = jest.fn()
const handlePointerLeave = jest.fn()
const {container} = render(
<div>
<button
onPointerEnter={handlePointerEnter}
onPointerLeave={handlePointerLeave}
/>
</div>,
)
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 {
Expand Down