Skip to content

Commit b96378c

Browse files
committed
test(query-broadcast-client-experimental): added initial tests
1 parent 6bc0b01 commit b96378c

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

packages/query-broadcast-client-experimental/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
"test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js --build",
2929
"test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js --build",
3030
"test:types:tscurrent": "tsc --build",
31+
"test:lib": "vitest",
32+
"test:lib:dev": "pnpm run test:lib --watch",
3133
"test:build": "publint --strict && attw --pack",
3234
"build": "tsup --tsconfig tsconfig.prod.json"
3335
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { QueryClient, QueryCache } from '@tanstack/query-core'
2+
import { describe, expect, it, beforeEach } from 'vitest'
3+
import { broadcastQueryClient } from '.'
4+
5+
describe('broadcastQueryClient', () => {
6+
let queryClient: QueryClient
7+
let queryCache: QueryCache
8+
9+
beforeEach(() => {
10+
queryClient = new QueryClient()
11+
queryCache = queryClient.getQueryCache()
12+
})
13+
14+
it('should subscribe to the query cache', async () => {
15+
broadcastQueryClient({
16+
queryClient,
17+
broadcastChannel: 'test_channel',
18+
})
19+
expect(queryCache.hasListeners()).toBe(true)
20+
})
21+
})

0 commit comments

Comments
 (0)