@@ -151,6 +151,14 @@ describe("createDiscordMonitorClient", () => {
|
151 | 151 | }; |
152 | 152 | } |
153 | 153 | |
| 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 | + |
154 | 162 | it("registers voice plugin listeners after gateway setup", async () => { |
155 | 163 | const gatewayPlugin = { |
156 | 164 | id: "gateway", |
@@ -240,8 +248,8 @@ describe("createDiscordMonitorClient", () => {
|
240 | 248 | }); |
241 | 249 | |
242 | 250 | 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({ |
245 | 253 | timeout: DISCORD_REST_TIMEOUT_MS, |
246 | 254 | runtimeProfile: "persistent", |
247 | 255 | maxQueueSize: 1000, |
@@ -275,8 +283,8 @@ describe("createDiscordMonitorClient", () => {
|
275 | 283 | }); |
276 | 284 | |
277 | 285 | 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({ |
280 | 288 | timeout: DISCORD_REST_TIMEOUT_MS, |
281 | 289 | runtimeProfile: "persistent", |
282 | 290 | maxQueueSize: 1000, |
|