refactor: split discord gateway helpers

This commit is contained in:
Peter Steinberger
2026-01-08 20:23:06 +01:00
parent bf67b29a0e
commit 393c414e90
3 changed files with 81 additions and 61 deletions

View File

@@ -2,7 +2,7 @@ import { EventEmitter } from "node:events";
import { describe, expect, it, vi } from "vitest";
import { waitForDiscordGatewayStop } from "./monitor.js";
import { waitForDiscordGatewayStop } from "./monitor.gateway.js";
describe("waitForDiscordGatewayStop", () => {
it("resolves on abort and disconnects gateway", async () => {
@@ -46,4 +46,16 @@ describe("waitForDiscordGatewayStop", () => {
abort.abort();
expect(disconnect).toHaveBeenCalledTimes(1);
});
it("resolves on abort without a gateway", async () => {
const abort = new AbortController();
const promise = waitForDiscordGatewayStop({
abortSignal: abort.signal,
});
abort.abort();
await expect(promise).resolves.toBeUndefined();
});
});