Skip to content

Commit 1ab7c7e

Browse files
committed
test: tighten heartbeat typing assertions
1 parent 7f9aefe commit 1ab7c7e

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

‎src/infra/heartbeat-runner.typing.test.ts‎

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ async function seedTelegramSession(storePath: string, cfg: OpenClawConfig) {
6464
});
6565
}
6666

67+
function expectTypingCall(
68+
mock: ReturnType<typeof vi.fn>,
69+
expected: { cfg: OpenClawConfig; to: string },
70+
) {
71+
const params = mock.mock.calls[0]?.[0] as { cfg?: unknown; to?: unknown } | undefined;
72+
if (!params) {
73+
throw new Error("missing typing call");
74+
}
75+
expect(params.cfg).toBe(expected.cfg);
76+
expect(params.to).toBe(expected.to);
77+
}
78+
6779
describe("runHeartbeatOnce heartbeat typing", () => {
6880
beforeEach(() => {
6981
setActivePluginRegistry(createTestRegistry());
@@ -87,18 +99,10 @@ describe("runHeartbeatOnce heartbeat typing", () => {
8799
},
88100
});
89101

90-
expect(sendTyping).toHaveBeenCalledWith(
91-
expect.objectContaining({
92-
cfg,
93-
to: TELEGRAM_TARGET,
94-
}),
95-
);
96-
expect(clearTyping).toHaveBeenCalledWith(
97-
expect.objectContaining({
98-
cfg,
99-
to: TELEGRAM_TARGET,
100-
}),
101-
);
102+
expect(sendTyping).toHaveBeenCalledOnce();
103+
expect(clearTyping).toHaveBeenCalledOnce();
104+
expectTypingCall(sendTyping, { cfg, to: TELEGRAM_TARGET });
105+
expectTypingCall(clearTyping, { cfg, to: TELEGRAM_TARGET });
102106
expect(sendTyping.mock.invocationCallOrder[0]).toBeLessThan(
103107
replySpy.mock.invocationCallOrder[0] ?? Number.POSITIVE_INFINITY,
104108
);

0 commit comments

Comments
 (0)