Skip to content

Commit a5940dd

Browse files
authored
Merge branch 'master' into patch-1
2 parents f6ca145 + c4cae93 commit a5940dd

File tree

5 files changed

+60
-5
lines changed

5 files changed

+60
-5
lines changed

.all-contributorsrc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,9 +1007,18 @@
10071007
"contributions": [
10081008
"doc"
10091009
]
1010+
},
1011+
{
1012+
"login": "zbrogz",
1013+
"name": "Zach Brogan",
1014+
"avatar_url": "https://avatars1.githubusercontent.com/u/319162?v=4",
1015+
"profile": "http://linkedin.com/in/zachbrogan",
1016+
"contributions": [
1017+
"code",
1018+
"test"
1019+
]
10101020
}
10111021
],
10121022
"contributorsPerLine": 7,
1013-
"repoHost": "https://github.com",
1014-
"skipCi": true
1023+
"repoHost": "https://github.com"
10151024
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ Thanks goes to these people ([emoji key][emojis]):
521521
<td align="center"><a href="http://www.laurensbosscher.nl"><img src="https://avatars0.githubusercontent.com/u/13363196?v=4" width="100px;" alt=""/><br /><sub><b>Laurens Bosscher</b></sub></a><br /><a href="https://github.com/testing-library/react-testing-library/commits?author=LaurensBosscher" title="Code">💻</a></td>
522522
<td align="center"><a href="https://twitter.com/__sakito__"><img src="https://avatars1.githubusercontent.com/u/15010907?v=4" width="100px;" alt=""/><br /><sub><b>Sakito Mukai</b></sub></a><br /><a href="https://github.com/testing-library/react-testing-library/commits?author=sakito21" title="Documentation">📖</a></td>
523523
<td align="center"><a href="http://turkerteke.com"><img src="https://avatars3.githubusercontent.com/u/12457162?v=4" width="100px;" alt=""/><br /><sub><b>Türker Teke</b></sub></a><br /><a href="https://github.com/testing-library/react-testing-library/commits?author=tteke" title="Documentation">📖</a></td>
524+
<td align="center"><a href="http://linkedin.com/in/zachbrogan"><img src="https://avatars1.githubusercontent.com/u/319162?v=4" width="100px;" alt=""/><br /><sub><b>Zach Brogan</b></sub></a><br /><a href="https://github.com/testing-library/react-testing-library/commits?author=zbrogz" title="Code">💻</a> <a href="https://github.com/testing-library/react-testing-library/commits?author=zbrogz" title="Tests">⚠️</a></td>
524525
</tr>
525526
</table>
526527

other/manual-releases.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ change is to release a new patch version.
4141
Reference: #<the number of a relevant pull request, issue, or commit>
4242
```
4343

44-
The number of times we've had to do a manual release is: 4
44+
The number of times we've had to do a manual release is: 5

src/__tests__/events.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,41 @@ eventTypes.forEach(({type, events, elementType, init}) => {
153153
})
154154
})
155155

156+
eventTypes.forEach(({type, events, elementType, init}) => {
157+
describe(`Native ${type} Events`, () => {
158+
events.forEach(eventName => {
159+
let nativeEventName = eventName.toLowerCase()
160+
161+
// The doubleClick synthetic event maps to the dblclick native event
162+
if (nativeEventName === 'doubleclick') {
163+
nativeEventName = 'dblclick'
164+
}
165+
166+
it(`triggers native ${nativeEventName}`, () => {
167+
const ref = React.createRef()
168+
const spy = jest.fn()
169+
const Element = elementType
170+
171+
const NativeEventElement = () => {
172+
React.useEffect(() => {
173+
const element = ref.current
174+
element.addEventListener(nativeEventName, spy)
175+
return () => {
176+
element.removeEventListener(nativeEventName, spy)
177+
}
178+
})
179+
return <Element ref={ref} />
180+
}
181+
182+
render(<NativeEventElement />)
183+
184+
fireEvent[eventName](ref.current, init)
185+
expect(spy).toHaveBeenCalledTimes(1)
186+
})
187+
})
188+
})
189+
})
190+
156191
test('onChange works', () => {
157192
const handleChange = jest.fn()
158193
const {

src/pure.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,20 @@ Object.keys(dtlFireEvent).forEach(key => {
128128
// React event system tracks native mouseOver/mouseOut events for
129129
// running onMouseEnter/onMouseLeave handlers
130130
// @link https://github.com/facebook/react/blob/b87aabdfe1b7461e7331abb3601d9e6bb27544bc/packages/react-dom/src/events/EnterLeaveEventPlugin.js#L24-L31
131-
fireEvent.mouseEnter = fireEvent.mouseOver
132-
fireEvent.mouseLeave = fireEvent.mouseOut
131+
const mouseEnter = fireEvent.mouseEnter
132+
const mouseLeave = fireEvent.mouseLeave
133+
fireEvent.mouseEnter = (...args) => {
134+
mouseEnter(...args)
135+
return fireEvent.mouseOver(...args)
136+
}
137+
fireEvent.mouseLeave = (...args) => {
138+
mouseLeave(...args)
139+
return fireEvent.mouseOut(...args)
140+
}
133141

142+
const select = fireEvent.select
134143
fireEvent.select = (node, init) => {
144+
select(node, init)
135145
// React tracks this event only on focused inputs
136146
node.focus()
137147

0 commit comments

Comments
 (0)