feat: create WebSocket client and real-time sync manager
This commit is contained in:
34
__tests__/lib/websocket/client.test.ts
Normal file
34
__tests__/lib/websocket/client.test.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { WebSocketClient } from '@/lib/websocket/client'
|
||||
|
||||
describe('WebSocketClient', () => {
|
||||
let client: WebSocketClient
|
||||
|
||||
beforeEach(() => {
|
||||
client = new WebSocketClient('ws://localhost:3011')
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
client.disconnect()
|
||||
})
|
||||
|
||||
it('should initialize WebSocket client', () => {
|
||||
expect(client).toBeDefined()
|
||||
expect(client.isConnected()).toBe(false)
|
||||
})
|
||||
|
||||
it('should track queue length when disconnected', () => {
|
||||
expect(client.getQueueLength()).toBe(0)
|
||||
client.send('highlight:create', { verseId: 'v-1', color: 'yellow' })
|
||||
expect(client.getQueueLength()).toBe(1)
|
||||
})
|
||||
|
||||
it('should get client ID', () => {
|
||||
const clientId = client.getClientId()
|
||||
expect(clientId).toBeDefined()
|
||||
expect(clientId.startsWith('client-')).toBe(true)
|
||||
})
|
||||
|
||||
it('should provide connection status', () => {
|
||||
expect(client.isConnected()).toBe(false)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user