mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-16 18:30:45 +00:00
test: clarify runtime event assertions
This commit is contained in:
@@ -1127,8 +1127,8 @@ describe("Initialization guard", () => {
|
||||
it("ensureContextEnginesInitialized() is idempotent and registers legacy", async () => {
|
||||
const { ensureContextEnginesInitialized } = await import("./init.js");
|
||||
|
||||
expect(() => ensureContextEnginesInitialized()).not.toThrow();
|
||||
expect(() => ensureContextEnginesInitialized()).not.toThrow();
|
||||
expect(ensureContextEnginesInitialized()).toBeUndefined();
|
||||
expect(ensureContextEnginesInitialized()).toBeUndefined();
|
||||
|
||||
const ids = listContextEngineIds();
|
||||
expect(ids).toContain("legacy");
|
||||
|
||||
@@ -234,8 +234,7 @@ describe("GatewayClient security checks", () => {
|
||||
onConnectError,
|
||||
});
|
||||
|
||||
// Should not throw
|
||||
expect(() => client.start()).not.toThrow();
|
||||
expect(client.start()).toBeUndefined();
|
||||
|
||||
expectSecurityConnectError(onConnectError);
|
||||
expect(wsInstances.length).toBe(0); // No WebSocket created
|
||||
@@ -535,9 +534,7 @@ describe("GatewayClient close handling", () => {
|
||||
const client = createClientWithIdentity("dev-2", onClose);
|
||||
|
||||
client.start();
|
||||
expect(() => {
|
||||
getLatestWs().emitClose(1008, "unauthorized: device token mismatch");
|
||||
}).not.toThrow();
|
||||
expect(getLatestWs().emitClose(1008, "unauthorized: device token mismatch")).toBeUndefined();
|
||||
|
||||
expect(logDebugMock).toHaveBeenCalledWith(
|
||||
expect.stringContaining("failed clearing stale device-auth token"),
|
||||
|
||||
@@ -210,7 +210,7 @@ describe("GatewayClient", () => {
|
||||
});
|
||||
|
||||
try {
|
||||
expect(() => client.start()).not.toThrow();
|
||||
expect(client.start()).toBeUndefined();
|
||||
await connected;
|
||||
expect(onConnectError).not.toHaveBeenCalled();
|
||||
} finally {
|
||||
|
||||
@@ -552,6 +552,6 @@ describe("talk realtime gateway relay", () => {
|
||||
expect(() => createSession("conn-1")).toThrow(
|
||||
"Too many active realtime relay sessions for this connection",
|
||||
);
|
||||
expect(() => createSession("conn-2")).not.toThrow();
|
||||
expect(createSession("conn-2")).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -177,7 +177,7 @@ describe("enableConsoleCapture", () => {
|
||||
enableConsoleCapture();
|
||||
const epipe = new Error("write EPIPE") as NodeJS.ErrnoException;
|
||||
epipe.code = "EPIPE";
|
||||
expect(() => stream.emit("error", epipe)).not.toThrow();
|
||||
expect(stream.emit("error", epipe)).toBe(true);
|
||||
});
|
||||
|
||||
it("rethrows non-EPIPE errors on stdout", () => {
|
||||
|
||||
@@ -48,12 +48,12 @@ describe("session lifecycle events", () => {
|
||||
const unsubscribeNoisy = onSessionLifecycleEvent(noisy.listener);
|
||||
const unsubscribeHealthy = onSessionLifecycleEvent(healthy.listener);
|
||||
|
||||
expect(() =>
|
||||
expect(
|
||||
emitSessionLifecycleEvent({
|
||||
sessionKey: "agent:main:main",
|
||||
reason: "resumed",
|
||||
}),
|
||||
).not.toThrow();
|
||||
).toBeUndefined();
|
||||
|
||||
expect(noisy.calls).toHaveLength(1);
|
||||
expect(healthy.calls).toHaveLength(1);
|
||||
|
||||
Reference in New Issue
Block a user