Skip to content

Commit dd52f77

Browse files
authored
add unit test for cacheTime: Infinity (#378)
1 parent 5f1e3a5 commit dd52f77

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/tests/useQuery.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,4 +732,22 @@ describe('useQuery', () => {
732732

733733
await waitForElement(() => rendered.getByText('isFetching === false'))
734734
})
735+
736+
test('should not schedule garbage collection, if cacheTimeout is set to `Infinity`', async () => {
737+
function Page() {
738+
const query = useQuery('test', () => 'fetched data', {
739+
cacheTime: Infinity,
740+
})
741+
return <div>{query.data}</div>
742+
}
743+
744+
const rendered = render(<Page />)
745+
746+
await waitForElement(() => rendered.getByText('fetched data'))
747+
748+
rendered.unmount()
749+
750+
const query = queryCache.getQuery('test')
751+
expect(query.cacheTimeout).toBe(undefined)
752+
})
735753
})

0 commit comments

Comments
 (0)