

























@@ -43,6 +43,14 @@ const pairingIdLabels: Record<string, string> = {
4343discord: "discordUserId",
4444};
454546+function requireFirstMockCall(calls: readonly unknown[][], label: string): unknown[] {
47+const call = calls.at(0);
48+if (!call) {
49+throw new Error(`expected ${label} call`);
50+}
51+return call;
52+}
53+4654vi.mock("../pairing/pairing-store.js", () => ({
4755listChannelPairingRequests: mocks.listChannelPairingRequests,
4856approveChannelPairingCode: mocks.approveChannelPairingCode,
@@ -226,9 +234,10 @@ describe("pairing cli", () => {
226234channel: "telegram",
227235code: "ABCDEFGH",
228236});
229-const replaceCall = replaceConfigFile.mock.calls[0]?.[0] as
230-| { nextConfig?: { commands?: { ownerAllowFrom?: string[] } } }
231-| undefined;
237+const replaceCall = requireFirstMockCall(
238+replaceConfigFile.mock.calls,
239+"config replace",
240+)[0] as { nextConfig?: { commands?: { ownerAllowFrom?: string[] } } } | undefined;
232241expect(replaceCall?.nextConfig?.commands?.ownerAllowFrom).toEqual(["telegram:123"]);
233242expect(log.mock.calls).toEqual([
234243[`${theme.success("Approved")} ${theme.muted("telegram")} sender ${theme.command("123")}.`],
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。