fix(discord): add DiscordVoiceReadyListener fire-and-forget error-path test

Add test covering the DiscordVoiceReadyListener.handle() path where
autoJoin() rejects, confirming the error is caught and does not propagate.
This commit is contained in:
geekhuashan
2026-04-03 23:21:53 +08:00
committed by Peter Steinberger
parent db593440c4
commit 0c575f37fd

View File

@@ -533,4 +533,15 @@ describe("DiscordVoiceManager", () => {
expect(client.fetchGuild).toHaveBeenCalledWith("g1");
expect(agentCommandMock).toHaveBeenCalledTimes(1);
});
it("DiscordVoiceReadyListener: propagates autoJoin errors fire-and-forget without throwing", async () => {
const manager = createManager();
vi.spyOn(manager, "autoJoin").mockRejectedValue(new Error("autoJoin rejected"));
const { DiscordVoiceReadyListener } = managerModule;
const listener = new DiscordVoiceReadyListener(manager);
await expect(listener.handle(undefined, undefined as never)).resolves.not.toThrow();
expect(manager.autoJoin).toHaveBeenCalledTimes(1);
});
});