feat: create WebSocket client and real-time sync manager

This commit is contained in:
2025-11-12 08:14:47 +00:00
parent c3a7d59002
commit 46ccc797a3
3 changed files with 239 additions and 0 deletions

View 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)
})
})