Skip to content

Commit 658d32b

Browse files
authored
test(query-core/queriesObserver): add test for 'combineResult' fallback when called without raw argument (#10511)
1 parent dbee9eb commit 658d32b

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

packages/query-core/src/__tests__/queriesObserver.test.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,29 @@ describe('queriesObserver', () => {
586586
expect(combined2.total).toBe(8)
587587
})
588588

589+
test('should use fallback result when combineResult is called without raw argument', () => {
590+
const combine = vi.fn((results: Array<QueryObserverResult>) => ({
591+
count: results.length,
592+
}))
593+
594+
const key = queryKey()
595+
const queryFn = vi.fn().mockReturnValue(1)
596+
597+
const observer = new QueriesObserver<{ count: number }>(
598+
queryClient,
599+
[{ queryKey: key, queryFn }],
600+
{ combine },
601+
)
602+
603+
const [, getCombined] = observer.getOptimisticResult(
604+
[{ queryKey: key, queryFn }],
605+
combine,
606+
)
607+
const combined = getCombined()
608+
609+
expect(combined.count).toBe(1)
610+
})
611+
589612
test('should track properties on all observers when trackResult is called', () => {
590613
const key1 = queryKey()
591614
const key2 = queryKey()

0 commit comments

Comments
 (0)