Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
raw
history blame
866 Bytes
import { QueryClient } from '@tanstack/query-core'
import { beforeEach, describe, expect, it } from 'vitest'
import { broadcastQueryClient } from '..'
import type { QueryCache } from '@tanstack/query-core'
describe('broadcastQueryClient', () => {
let queryClient: QueryClient
let queryCache: QueryCache
beforeEach(() => {
queryClient = new QueryClient()
queryCache = queryClient.getQueryCache()
})
it('should subscribe to the query cache', () => {
broadcastQueryClient({
queryClient,
broadcastChannel: 'test_channel',
})
expect(queryCache.hasListeners()).toBe(true)
})
it('should not have any listeners after cleanup', () => {
const unsubscribe = broadcastQueryClient({
queryClient,
broadcastChannel: 'test_channel',
})
unsubscribe()
expect(queryCache.hasListeners()).toBe(false)
})
})