diff --git a/core/test/manager.test.ts b/core/test/manager.test.ts index 4f684191..75197756 100644 --- a/core/test/manager.test.ts +++ b/core/test/manager.test.ts @@ -1,4 +1,5 @@ import { APIManager } from "../src/manager.ts"; +import { wait } from "./wait.ts"; Deno.test("mix rest and gateway", async () => { const client = new APIManager(Deno.env.get("BOT_TOKEN")!, { @@ -8,7 +9,6 @@ Deno.test("mix rest and gateway", async () => { }); client.on("READY", async () => { - console.log("READY"); await client.post(`/channels/749139969192230995/messages`, { body: { content: "test", @@ -18,4 +18,6 @@ Deno.test("mix rest and gateway", async () => { }); await client.spawnAndRunAll(); + + await wait(); }); diff --git a/core/test/wait.ts b/core/test/wait.ts new file mode 100644 index 00000000..7f99600a --- /dev/null +++ b/core/test/wait.ts @@ -0,0 +1,11 @@ +/** + * Wait for a given amount of time. This is here because Deno test can't properly handle events. + * @param ms The amount of time to wait in milliseconds. + * @returns A promise that resolves after the given amount of time. + */ +export const wait = async (ms: number = 1000): Promise => { + let id: number = 0; + await new Promise((resolve) => id = setTimeout(resolve, ms)); + clearTimeout(id); + return; +};