perf(test): remove timer waits in hooks and discord monitor tests

This commit is contained in:
Peter Steinberger
2026-02-18 16:45:48 +00:00
parent 4605dfd2ae
commit 36996194cd
2 changed files with 2 additions and 3 deletions

View File

@@ -1,6 +1,5 @@
import { ChannelType, type Guild } from "@buape/carbon"; import { ChannelType, type Guild } from "@buape/carbon";
import { describe, expect, it, vi } from "vitest"; import { describe, expect, it, vi } from "vitest";
import { sleep } from "../utils.js";
import { import {
allowListMatches, allowListMatches,
buildDiscordMediaPayload, buildDiscordMediaPayload,
@@ -108,7 +107,7 @@ describe("DiscordMessageListener", () => {
{} as unknown as import("./monitor/listeners.js").DiscordMessageEvent, {} as unknown as import("./monitor/listeners.js").DiscordMessageEvent,
{} as unknown as import("@buape/carbon").Client, {} as unknown as import("@buape/carbon").Client,
); );
await sleep(0); await Promise.resolve();
expect(logger.error).toHaveBeenCalledWith(expect.stringContaining("discord handler failed")); expect(logger.error).toHaveBeenCalledWith(expect.stringContaining("discord handler failed"));
}); });

View File

@@ -109,7 +109,7 @@ describe("hooks", () => {
it("should handle async handlers", async () => { it("should handle async handlers", async () => {
const handler = vi.fn(async () => { const handler = vi.fn(async () => {
await new Promise((resolve) => setTimeout(resolve, 10)); await Promise.resolve();
}); });
registerInternalHook("command:new", handler); registerInternalHook("command:new", handler);