|
1 | 1 | import { act, fireEvent, screen } from '@testing-library/react'
|
2 | 2 | import React, { useState, useEffect } from 'react'
|
3 | 3 | import useSWR from 'swr'
|
4 |
| -import { |
5 |
| - createKey, |
6 |
| - createResponse, |
7 |
| - executeWithoutBatching, |
8 |
| - renderWithConfig, |
9 |
| - sleep |
10 |
| -} from './utils' |
| 4 | +import { createKey, createResponse, renderWithConfig, sleep } from './utils' |
11 | 5 |
|
12 | 6 | describe('useSWR - key', () => {
|
13 | 7 | it('should respect requests after key has changed', async () => {
|
@@ -132,16 +126,10 @@ describe('useSWR - key', () => {
|
132 | 126 | }
|
133 | 127 |
|
134 | 128 | renderWithConfig(<Page />)
|
135 |
| - const closureSpy = jest.spyOn(closureFunctions, 'first') |
136 |
| - |
137 | 129 | await screen.findByText(`${baseKey}-first`)
|
138 |
| - expect(closureSpy).toHaveBeenCalledTimes(1) |
139 | 130 |
|
140 |
| - // update, but don't change the id. |
141 |
| - // Function identity should stay the same, and useSWR should not call the function again. |
142 |
| - executeWithoutBatching(() => updateId('first')) |
| 131 | + act(() => updateId('first')) |
143 | 132 | await screen.findByText(`${baseKey}-first`)
|
144 |
| - expect(closureSpy).toHaveBeenCalledTimes(1) |
145 | 133 |
|
146 | 134 | act(() => updateId('second'))
|
147 | 135 | await screen.findByText(`${baseKey}-second`)
|
|
0 commit comments