We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 240900c commit ba59d1fCopy full SHA for ba59d1f
src/__tests__/render.js
@@ -1,6 +1,8 @@
1
import React from 'react'
2
import ReactDOM from 'react-dom'
3
import {render, screen} from '../'
4
+import {cleanup} from '../pure'
5
+import {act} from 'react-dom/test-utils'
6
7
test('renders div into document', () => {
8
const ref = React.createRef()
@@ -87,3 +89,17 @@ test('renders options.wrapper around node', () => {
87
89
</div>
88
90
`)
91
})
92
+
93
+test('flushes useEffect cleanup functions sync on unmount()', () => {
94
+ const spy = jest.fn()
95
+ function Component() {
96
+ React.useEffect(() => spy, [])
97
+ return null
98
+ }
99
+ const {unmount} = render(<Component />)
100
+ expect(spy).toHaveBeenCalledTimes(0)
101
102
+ unmount()
103
104
+ expect(spy).toHaveBeenCalledTimes(1)
105
+})
0 commit comments