Skip to content

Commit 3cbc889

Browse files
committed
test: guard discord provider startup mock calls
1 parent 7517fe5 commit 3cbc889

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

‎extensions/discord/src/monitor/provider.startup.test.ts‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,14 @@ describe("createDiscordMonitorClient", () => {
151151
};
152152
}
153153

154+
function firstCreateClientCall(createClient: { mock: { calls: unknown[][] } }) {
155+
const [call] = createClient.mock.calls;
156+
if (!call) {
157+
throw new Error("expected Discord client creation call");
158+
}
159+
return call;
160+
}
161+
154162
it("registers voice plugin listeners after gateway setup", async () => {
155163
const gatewayPlugin = {
156164
id: "gateway",
@@ -240,8 +248,8 @@ describe("createDiscordMonitorClient", () => {
240248
});
241249

242250
expect(createClient).toHaveBeenCalledTimes(1);
243-
const [options, handlers, plugins] = createClient.mock.calls[0] ?? [];
244-
expect(options?.requestOptions).toEqual({
251+
const [options, handlers, plugins] = firstCreateClientCall(createClient);
252+
expect((options as { requestOptions?: unknown } | undefined)?.requestOptions).toEqual({
245253
timeout: DISCORD_REST_TIMEOUT_MS,
246254
runtimeProfile: "persistent",
247255
maxQueueSize: 1000,
@@ -275,8 +283,8 @@ describe("createDiscordMonitorClient", () => {
275283
});
276284

277285
expect(createClient).toHaveBeenCalledTimes(1);
278-
const [options, handlers, plugins] = createClient.mock.calls[0] ?? [];
279-
expect(options?.requestOptions).toEqual({
286+
const [options, handlers, plugins] = firstCreateClientCall(createClient);
287+
expect((options as { requestOptions?: unknown } | undefined)?.requestOptions).toEqual({
280288
timeout: DISCORD_REST_TIMEOUT_MS,
281289
runtimeProfile: "persistent",
282290
maxQueueSize: 1000,

0 commit comments

Comments
 (0)