
























@@ -27,6 +27,14 @@ beforeAll(async () => {
2727({ createQQWSClient } = await import("./ws-client.js"));
2828});
292930+function expectWebSocketCtorCall(expected: unknown[]): void {
31+const call = webSocketCtorMock.mock.calls.at(0);
32+if (!call) {
33+throw new Error("Expected WebSocket constructor call");
34+}
35+expect(call).toEqual(expected);
36+}
37+3038describe("createQQWSClient", () => {
3139beforeEach(() => {
3240priorProxyEnv = {};
@@ -56,7 +64,7 @@ describe("createQQWSClient", () => {
56645765expect(webSocketCtorMock).toHaveBeenCalledTimes(1);
5866expect(proxyAgentCtorMock).not.toHaveBeenCalled();
59-expect(webSocketCtorMock.mock.calls[0]).toEqual([
67+expectWebSocketCtorCall([
6068"wss://qq.example.test/ws",
6169{
6270headers: { "User-Agent": "openclaw-qqbot-test" },
@@ -74,7 +82,7 @@ describe("createQQWSClient", () => {
74827583expect(webSocketCtorMock).toHaveBeenCalledTimes(1);
7684expect(proxyAgentCtorMock).toHaveBeenCalledTimes(1);
77-expect(webSocketCtorMock.mock.calls[0]).toEqual([
85+expectWebSocketCtorCall([
7886"wss://qq.example.test/ws",
7987{
8088agent: { proxied: true },
@@ -93,7 +101,7 @@ describe("createQQWSClient", () => {
9310194102expect(webSocketCtorMock).toHaveBeenCalledTimes(1);
95103expect(proxyAgentCtorMock).toHaveBeenCalledTimes(1);
96-expect(webSocketCtorMock.mock.calls[0]).toEqual([
104+expectWebSocketCtorCall([
97105"wss://qq.example.test/ws",
98106{
99107agent: { proxied: true },
@@ -112,7 +120,7 @@ describe("createQQWSClient", () => {
112120113121expect(webSocketCtorMock).toHaveBeenCalledTimes(1);
114122expect(proxyAgentCtorMock).toHaveBeenCalledTimes(1);
115-expect(webSocketCtorMock.mock.calls[0]).toEqual([
123+expectWebSocketCtorCall([
116124"wss://qq.example.test/ws",
117125{
118126agent: { proxied: true },
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。