Skip to content

Commit af23b46

Browse files
committed
Adjust test expecations
1 parent 797c11b commit af23b46

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/__tests__/cleanup.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('fake timers and missing act warnings', () => {
5555
jest.useRealTimers()
5656
})
5757

58-
test('cleanup does not flush microtasks', async () => {
58+
test('cleanup does flush microtasks', async () => {
5959
const microTaskSpy = jest.fn()
6060
function Test() {
6161
const counter = 1
@@ -72,16 +72,19 @@ describe('fake timers and missing act warnings', () => {
7272

7373
return () => {
7474
cancelled = true
75+
Promise.resolve().then(() => {
76+
microTaskSpy()
77+
})
7578
}
7679
}, [counter])
7780

7881
return null
7982
}
8083
await render(<Test />)
84+
expect(microTaskSpy).toHaveBeenCalledTimes(1)
8185

8286
await cleanup()
83-
84-
expect(microTaskSpy).toHaveBeenCalledTimes(0)
87+
expect(microTaskSpy).toHaveBeenCalledTimes(2)
8588
// console.error is mocked
8689
// eslint-disable-next-line no-console
8790
expect(console.error).toHaveBeenCalledTimes(0)

0 commit comments

Comments
 (0)