test: clarify runtime event assertions · openclaw/openclaw@d0f484d
steipete
·
2026-05-08
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1127,8 +1127,8 @@ describe("Initialization guard", () => {
|
1127 | 1127 | it("ensureContextEnginesInitialized() is idempotent and registers legacy", async () => { |
1128 | 1128 | const { ensureContextEnginesInitialized } = await import("./init.js"); |
1129 | 1129 | |
1130 | | -expect(() => ensureContextEnginesInitialized()).not.toThrow(); |
1131 | | -expect(() => ensureContextEnginesInitialized()).not.toThrow(); |
| 1130 | +expect(ensureContextEnginesInitialized()).toBeUndefined(); |
| 1131 | +expect(ensureContextEnginesInitialized()).toBeUndefined(); |
1132 | 1132 | |
1133 | 1133 | const ids = listContextEngineIds(); |
1134 | 1134 | expect(ids).toContain("legacy"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -234,8 +234,7 @@ describe("GatewayClient security checks", () => {
|
234 | 234 | onConnectError, |
235 | 235 | }); |
236 | 236 | |
237 | | -// Should not throw |
238 | | -expect(() => client.start()).not.toThrow(); |
| 237 | +expect(client.start()).toBeUndefined(); |
239 | 238 | |
240 | 239 | expectSecurityConnectError(onConnectError); |
241 | 240 | expect(wsInstances.length).toBe(0); // No WebSocket created |
@@ -535,9 +534,7 @@ describe("GatewayClient close handling", () => {
|
535 | 534 | const client = createClientWithIdentity("dev-2", onClose); |
536 | 535 | |
537 | 536 | client.start(); |
538 | | -expect(() => { |
539 | | -getLatestWs().emitClose(1008, "unauthorized: device token mismatch"); |
540 | | -}).not.toThrow(); |
| 537 | +expect(getLatestWs().emitClose(1008, "unauthorized: device token mismatch")).toBeUndefined(); |
541 | 538 | |
542 | 539 | expect(logDebugMock).toHaveBeenCalledWith( |
543 | 540 | expect.stringContaining("failed clearing stale device-auth token"), |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -210,7 +210,7 @@ describe("GatewayClient", () => {
|
210 | 210 | }); |
211 | 211 | |
212 | 212 | try { |
213 | | -expect(() => client.start()).not.toThrow(); |
| 213 | +expect(client.start()).toBeUndefined(); |
214 | 214 | await connected; |
215 | 215 | expect(onConnectError).not.toHaveBeenCalled(); |
216 | 216 | } finally { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -552,6 +552,6 @@ describe("talk realtime gateway relay", () => {
|
552 | 552 | expect(() => createSession("conn-1")).toThrow( |
553 | 553 | "Too many active realtime relay sessions for this connection", |
554 | 554 | ); |
555 | | -expect(() => createSession("conn-2")).not.toThrow(); |
| 555 | +expect(createSession("conn-2")).toBeDefined(); |
556 | 556 | }); |
557 | 557 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -177,7 +177,7 @@ describe("enableConsoleCapture", () => {
|
177 | 177 | enableConsoleCapture(); |
178 | 178 | const epipe = new Error("write EPIPE") as NodeJS.ErrnoException; |
179 | 179 | epipe.code = "EPIPE"; |
180 | | -expect(() => stream.emit("error", epipe)).not.toThrow(); |
| 180 | +expect(stream.emit("error", epipe)).toBe(true); |
181 | 181 | }); |
182 | 182 | |
183 | 183 | it("rethrows non-EPIPE errors on stdout", () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -48,12 +48,12 @@ describe("session lifecycle events", () => {
|
48 | 48 | const unsubscribeNoisy = onSessionLifecycleEvent(noisy.listener); |
49 | 49 | const unsubscribeHealthy = onSessionLifecycleEvent(healthy.listener); |
50 | 50 | |
51 | | -expect(() => |
| 51 | +expect( |
52 | 52 | emitSessionLifecycleEvent({ |
53 | 53 | sessionKey: "agent:main:main", |
54 | 54 | reason: "resumed", |
55 | 55 | }), |
56 | | -).not.toThrow(); |
| 56 | +).toBeUndefined(); |
57 | 57 | |
58 | 58 | expect(noisy.calls).toHaveLength(1); |
59 | 59 | expect(healthy.calls).toHaveLength(1); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。