


























@@ -104,6 +104,14 @@ function createConfigWithDiscordAccount(overrides: Record<string, unknown> = {})
104104105105type MockCallReader = { mock: { calls: unknown[][] } };
106106107+function firstMockArg(mock: MockCallReader, label: string) {
108+const firstCall = mock.mock.calls.at(0);
109+if (!firstCall) {
110+throw new Error(`expected ${label} mock call`);
111+}
112+return firstCall[0];
113+}
114+107115function mockMessages(mock: unknown): string[] {
108116return (mock as MockCallReader).mock.calls.map((call) => {
109117const message = call[0];
@@ -154,7 +162,7 @@ describe("monitorDiscordProvider", () => {
154162| { listenerTimeout?: number; slowListenerThreshold?: number }
155163| undefined => {
156164expect(clientConstructorOptionsMock).toHaveBeenCalledTimes(1);
157-const opts = clientConstructorOptionsMock.mock.calls[0]?.[0] as {
165+const opts = firstMockArg(clientConstructorOptionsMock, "Discord client constructor") as {
158166eventQueue?: { listenerTimeout?: number; slowListenerThreshold?: number };
159167};
160168return opts.eventQueue;
@@ -166,13 +174,11 @@ describe("monitorDiscordProvider", () => {
166174requestOptions?: { timeout?: number; runtimeProfile?: string; maxQueueSize?: number };
167175} => {
168176expect(clientConstructorOptionsMock).toHaveBeenCalledTimes(1);
169-return (
170-(clientConstructorOptionsMock.mock.calls[0]?.[0] as {
171-clientId?: string;
172-eventQueue?: { listenerTimeout?: number; slowListenerThreshold?: number };
173-requestOptions?: { timeout?: number; runtimeProfile?: string; maxQueueSize?: number };
174-}) ?? {}
175-);
177+return firstMockArg(clientConstructorOptionsMock, "Discord client constructor") as {
178+clientId?: string;
179+eventQueue?: { listenerTimeout?: number; slowListenerThreshold?: number };
180+requestOptions?: { timeout?: number; runtimeProfile?: string; maxQueueSize?: number };
181+};
176182};
177183178184const getHealthProbe = () => {
@@ -693,7 +699,7 @@ describe("monitorDiscordProvider", () => {
693699reason: "status-timeout",
694700});
695701696-const firstCall = getAcpSessionStatusMock.mock.calls[0]?.[0] as
702+const firstCall = firstMockArg(getAcpSessionStatusMock, "ACP session status") as
697703| { signal?: AbortSignal }
698704| undefined;
699705if (!firstCall?.signal) {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。