mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-19 03:14:46 +00:00
test: guard heartbeat prefix mock call
This commit is contained in:
@@ -51,6 +51,14 @@ describe("runHeartbeatOnce responsePrefix templates", () => {
|
||||
});
|
||||
}
|
||||
|
||||
function requireFirstMockCall<T>(mock: { mock: { calls: T[][] } }, label: string): T[] {
|
||||
const call = mock.mock.calls.at(0);
|
||||
if (!call) {
|
||||
throw new Error(`expected ${label} call`);
|
||||
}
|
||||
return call;
|
||||
}
|
||||
|
||||
async function runTemplatedHeartbeat(params: { responsePrefix: string; replyText: string }) {
|
||||
return withTempTelegramHeartbeatSandbox(async ({ tmpDir, storePath, replySpy }) => {
|
||||
const cfg = createTelegramHeartbeatConfig({
|
||||
@@ -93,7 +101,7 @@ describe("runHeartbeatOnce responsePrefix templates", () => {
|
||||
});
|
||||
|
||||
expect(sendTelegram).toHaveBeenCalledTimes(1);
|
||||
const [target, message, options] = sendTelegram.mock.calls[0] ?? [];
|
||||
const [target, message, options] = requireFirstMockCall(sendTelegram, "telegram send");
|
||||
expect(target).toBe(TELEGRAM_GROUP);
|
||||
expect(message).toBe("[openai-codex/gpt-5.4|think:high] Heartbeat alert");
|
||||
expect(typeof options).toBe("object");
|
||||
|
||||
Reference in New Issue
Block a user