


























@@ -59,6 +59,15 @@ function countMatching<T>(items: readonly T[], predicate: (item: T) => boolean):
5959return count;
6060}
616162+function registeredCommands(callIndex = -1): Array<{ command: string; description: string }> {
63+const resolvedIndex = callIndex < 0 ? setMyCommandsSpy.mock.calls.length + callIndex : callIndex;
64+const call = setMyCommandsSpy.mock.calls[resolvedIndex];
65+if (!call) {
66+throw new Error(`expected setMyCommands call ${callIndex}`);
67+}
68+return call[0] as Array<{ command: string; description: string }>;
69+}
70+6271describe("createTelegramBot command menu", () => {
6372beforeAll(async () => {
6473({ normalizeTelegramCommandName } = await import("./command-config.js"));
@@ -120,10 +129,7 @@ describe("createTelegramBot command menu", () => {
120129121130await commandsSynced;
122131123-const registered = setMyCommandsSpy.mock.calls.at(-1)?.[0] as Array<{
124-command: string;
125-description: string;
126-}>;
132+const registered = registeredCommands();
127133const skillCommands = resolveSkillCommands(config);
128134const native = listNativeCommandSpecsForConfig(config, { skillCommands }).map((command) => ({
129135command: normalizeTelegramCommandName(command.name),
@@ -174,10 +180,7 @@ describe("createTelegramBot command menu", () => {
174180175181await commandsSynced;
176182177-const registered = setMyCommandsSpy.mock.calls.at(-1)?.[0] as Array<{
178-command: string;
179-description: string;
180-}>;
183+const registered = registeredCommands();
181184const skillCommands = resolveSkillCommands(config);
182185const native = listNativeCommandSpecsForConfig(config, { skillCommands }).map((command) => ({
183186command: normalizeTelegramCommandName(command.name),
@@ -222,10 +225,7 @@ describe("createTelegramBot command menu", () => {
222225223226await commandsSynced;
224227225-const registered = setMyCommandsSpy.mock.calls.at(0)?.[0] as Array<{
226-command: string;
227-description: string;
228-}>;
228+const registered = registeredCommands(0);
229229expect(registered).toEqual([
230230{ command: "custom_backup", description: "Git backup" },
231231{ command: "custom_generate", description: "Create an image" },
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。