Skip to content

Commit 9350dbf

Browse files
committed
fix: update live client tests to handle enhanced error events
After rebasing with main, error events now include enhanced debugging information with additional properties like statusCode, requestId, responseHeaders, url, readyState, and a DeepgramWebSocketError object. Updated unit tests to expect the new enhanced error structure while maintaining test coverage for error handling functionality.
1 parent 5d85b4b commit 9350dbf

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

tests/unit/live-client-connection-state.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,14 @@ describe("Unit Tests - Live Client Connection State", () => {
356356
const errorEvent = { type: "error", message: "Connection failed" };
357357
mockConnection.onerror(errorEvent);
358358

359-
expect(errorSpy).toHaveBeenCalledWith(errorEvent);
359+
expect(errorSpy).toHaveBeenCalledWith(
360+
expect.objectContaining({
361+
type: "error",
362+
message: expect.stringContaining("Connection failed"),
363+
error: expect.any(Object),
364+
readyState: expect.any(Number),
365+
})
366+
);
360367
});
361368
});
362369
});

tests/unit/live-client-message-handling.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,14 @@ describe("Unit Tests - Live Client Message Handling", () => {
6969
// Simulate connection error
7070
mockConnection.onerror(errorEvent);
7171

72-
expect(errorSpy).toHaveBeenCalledWith(errorEvent);
72+
expect(errorSpy).toHaveBeenCalledWith(
73+
expect.objectContaining({
74+
type: "error",
75+
message: expect.stringContaining("Connection failed"),
76+
error: expect.any(Object),
77+
readyState: expect.any(Number),
78+
})
79+
);
7380
});
7481

7582
it("should handle Transcript messages correctly", () => {

0 commit comments

Comments
 (0)