]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
feat(common): add notification callback support to WebSocketClient
authorJérôme Benoit <jerome.benoit@sap.com>
Wed, 15 Apr 2026 21:02:00 +0000 (23:02 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Wed, 15 Apr 2026 21:02:00 +0000 (23:02 +0200)
ui/common/tests/WebSocketClient.test.ts

index 1e28e8c7e6a0046e318006b8958df7bc91803777..a02339294a4f998b491a815bcd3944cdd4a90718 100644 (file)
@@ -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