Files
erika/lib/leaderboard/discord.test.ts
T

22 lines
883 B
TypeScript

import { describe, expect, test } from "bun:test";
import { parseCurrentVoiceChannels } from "@/lib/leaderboard/discord";
describe("Discord current voice channels", () => {
test("keeps voice and Stage channels in stable position order", () => {
expect(parseCurrentVoiceChannels([
{ id: "text", name: "general", type: 0, position: 0 },
{ id: "stage", name: "Stage", type: 13, position: 3 },
{ id: "voice-b", name: "Beta", type: 2, position: 2 },
{ id: "voice-a", name: "Alpha", type: 2, position: 2 },
])).toEqual([
{ id: "voice-a", name: "Alpha", type: 2, position: 2 },
{ id: "voice-b", name: "Beta", type: 2, position: 2 },
{ id: "stage", name: "Stage", type: 13, position: 3 },
]);
});
test("rejects malformed top-level data", () => {
expect(() => parseCurrentVoiceChannels({ channels: [] })).toThrow();
});
});