mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 11:08:37 +00:00
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
|
|
const logDebugMock = vi.hoisted(() => vi.fn());
|
|
|
|
vi.mock("../logger.js", () => ({
|
|
logDebug: (...args: unknown[]) => logDebugMock(...args),
|
|
}));
|
|
|
|
const { ignoreCiaoCancellationRejection } = await import("./bonjour-ciao.js");
|
|
|
|
describe("bonjour-ciao", () => {
|
|
it("ignores and logs ciao cancellation rejections", () => {
|
|
expect(
|
|
ignoreCiaoCancellationRejection(new Error("Ciao announcement cancelled by shutdown")),
|
|
).toBe(true);
|
|
expect(logDebugMock).toHaveBeenCalledWith(
|
|
expect.stringContaining("ignoring unhandled ciao rejection"),
|
|
);
|
|
});
|
|
|
|
it("ignores lower-case string cancellation reasons too", () => {
|
|
logDebugMock.mockReset();
|
|
|
|
expect(ignoreCiaoCancellationRejection("ciao announcement cancelled during cleanup")).toBe(
|
|
true,
|
|
);
|
|
expect(logDebugMock).toHaveBeenCalledWith(
|
|
expect.stringContaining("ignoring unhandled ciao rejection"),
|
|
);
|
|
});
|
|
|
|
it("keeps unrelated rejections visible", () => {
|
|
logDebugMock.mockReset();
|
|
|
|
expect(ignoreCiaoCancellationRejection(new Error("boom"))).toBe(false);
|
|
expect(logDebugMock).not.toHaveBeenCalled();
|
|
});
|
|
});
|