Skip to content

Commit

Permalink
chore: ws test
Browse files Browse the repository at this point in the history
  • Loading branch information
onmax committed Jan 14, 2025
1 parent 83c1cfc commit 49f0aaf
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/ws.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// import { http, ws } from 'msw'
// import { setupServer } from 'msw/node'
// import { NimiqRPCClient } from 'src'
// import { afterAll, afterEach, beforeAll, describe, expect, it } from 'vitest'

// const client = new NimiqRPCClient('http://localhost:8648')
// client.ws.url.pathname = '/'

// const api = ws.link(client.ws.url.href)

// export const handlers = [
// http.get('http://localhost:8648/', ({ request }) => {
// console.log('Intercepted a request:', request.method, request.url)
// }),
// http.post('http://localhost:8648/', ({ request }) => {
// console.log('Intercepted a request:', request.method, request.url)
// }),
// // http.all('*', (req, res) => {
// // console.log('Intercepted a request:', req.method, req.url)
// // return res(req.body)
// // }),
// api.addEventListener('connection', ({ client }) => {
// console.log('Intercepted a WebSocket connection:', client.url)
// }),
// api.addEventListener('connection', ({ client }) => {
// console.log('Intercepted a WebSocket connection:', client.url)
// }),
// ]
// const server = setupServer(...handlers)

// beforeAll(() => server.listen())
// afterEach(() => server.resetHandlers())
// afterAll(() => server.close())

// describe('test for subscriptions with mock web socket', async () => {
// it('subscribe to hash blocks', async () => {
// const { data } = await client.policy.getPolicyConstants()
// const { next, close } = await client.blockchainStreams.subscribeForBlockHashes()

// next(({ data }) => {
// expect(data).toBe('test-hash')
// // close()
// })

// // open-rpc message from server
// // server.send({ data: 'test-hash' })
// })
// })

0 comments on commit 49f0aaf

Please sign in to comment.