Skip to content

Commit b9524d1

Browse files
authored
add test case that covers #1286 (#1297)
1 parent 9e1e9fb commit b9524d1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/use-swr-infinite.test.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,4 +629,25 @@ describe('useSWRInfinite', () => {
629629
)
630630
await screen.findByText('data:local-mutation')
631631
})
632+
633+
it('should correctly set size when key is null', async () => {
634+
const loggedValues = []
635+
636+
function Page() {
637+
const { size, setSize } = useSWRInfinite<string, string>(
638+
() => null,
639+
() => ''
640+
)
641+
loggedValues.push(size)
642+
return <button onClick={() => setSize(1)}>set size</button>
643+
}
644+
645+
render(<Page />)
646+
647+
await screen.findByText('set size')
648+
fireEvent.click(screen.getByText('set size'))
649+
await act(() => sleep(1))
650+
651+
expect(loggedValues).toEqual([1])
652+
})
632653
})

0 commit comments

Comments
 (0)