From: Jérôme Benoit Date: Wed, 15 Apr 2026 21:02:00 +0000 (+0200) Subject: feat(common): add notification callback support to WebSocketClient X-Git-Tag: cli@v4.5.0~81 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=a92b7442aa0c0e82bd0870c61d8069d9582a0a8d;p=e-mobility-charging-stations-simulator.git feat(common): add notification callback support to WebSocketClient --- diff --git a/ui/common/tests/WebSocketClient.test.ts b/ui/common/tests/WebSocketClient.test.ts index 1e28e8c7..a0233929 100644 --- a/ui/common/tests/WebSocketClient.test.ts +++ b/ui/common/tests/WebSocketClient.test.ts @@ -533,7 +533,9 @@ await describe('WebSocketClient', async () => { () => mockWs, { host: 'localhost', port: 8080, protocol: 'ui', version: '0.0.1' }, undefined, - notification => { notifications.push(notification) } + notification => { + notifications.push(notification) + } ) const connectPromise = client.connect() mockWs.triggerOpen() @@ -554,14 +556,16 @@ await describe('WebSocketClient', async () => { factory, { host: 'localhost', port: 8080, protocol: 'ui', version: '0.0.1' }, undefined, - notification => { notifications.push(notification) } + notification => { + notifications.push(notification) + } ) const connectPromise = client.connect() mockWs.triggerOpen() await connectPromise const requestPromise = client.sendRequest(ProcedureName.SIMULATOR_STATE, {}) - const uuid = JSON.parse(mockWs.sentMessages[0])[0] as string + const uuid = (JSON.parse(mockWs.sentMessages[0]) as unknown[])[0] as string mockWs.triggerMessage(JSON.stringify([uuid, { status: ResponseStatus.SUCCESS }])) await requestPromise @@ -571,10 +575,12 @@ await describe('WebSocketClient', async () => { await it('should NOT fire onNotification when callback is undefined', async () => { const mockWs = createMockWs() - const client = new WebSocketClient( - () => mockWs, - { host: 'localhost', port: 8080, protocol: 'ui', version: '0.0.1' } - ) + const client = new WebSocketClient(() => mockWs, { + host: 'localhost', + port: 8080, + protocol: 'ui', + version: '0.0.1', + }) const connectPromise = client.connect() mockWs.triggerOpen() await connectPromise