Skip to content

Commit 83a1ba6

Browse files
committed
test: add query defaults test
1 parent 65f9f12 commit 83a1ba6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/core/tests/queryCache.test.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,19 @@ describe('queryCache', () => {
4747
expect(data).toBe('data')
4848
})
4949

50+
test('setQueryDefaults should not match if the query key is a subset', async () => {
51+
const consoleMock = mockConsoleError()
52+
const key = queryKey()
53+
queryClient.setQueryDefaults([key, 'a'], { queryFn: () => 'data' })
54+
const observer = new QueryObserver(queryClient, {
55+
queryKey: [key],
56+
retry: false,
57+
})
58+
const { status } = await observer.refetch()
59+
expect(status).toBe('error')
60+
consoleMock.mockRestore()
61+
})
62+
5063
test('setQueryData does not crash if query could not be found', () => {
5164
const key = queryKey()
5265

0 commit comments

Comments
 (0)