Skip to content

Commit

Permalink
add test case that covers #1286 (#1297)
Browse files Browse the repository at this point in the history
  • Loading branch information
shuding committed Jul 18, 2021
1 parent 9e1e9fb commit b9524d1
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/use-swr-infinite.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -629,4 +629,25 @@ describe('useSWRInfinite', () => {
)
await screen.findByText('data:local-mutation')
})

it('should correctly set size when key is null', async () => {
const loggedValues = []

function Page() {
const { size, setSize } = useSWRInfinite<string, string>(
() => null,
() => ''
)
loggedValues.push(size)
return <button onClick={() => setSize(1)}>set size</button>
}

render(<Page />)

await screen.findByText('set size')
fireEvent.click(screen.getByText('set size'))
await act(() => sleep(1))

expect(loggedValues).toEqual([1])
})
})

0 comments on commit b9524d1

Please sign in to comment.