Skip to content

Commit 9d520f7

Browse files
committed
test(discord): widen voice channel mock type
1 parent ff90f9e commit 9d520f7

1 file changed

Lines changed: 24 additions & 6 deletions

File tree

extensions/discord/src/voice/manager.e2e.test.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,17 +231,35 @@ vi.mock("../runtime.js", () => ({
231231

232232
let managerModule: typeof import("./manager.js");
233233

234+
function createVoiceChannelInfo(
235+
channelId: string,
236+
guildId = "g1",
237+
guildName = "Guild One",
238+
): {
239+
id: string;
240+
guildId: string;
241+
guild: { id: string; name: string };
242+
type: ChannelType;
243+
} {
244+
return {
245+
id: channelId,
246+
guildId,
247+
guild: { id: guildId, name: guildName },
248+
type: ChannelType.GuildVoice,
249+
};
250+
}
251+
252+
type VoiceChannelInfo = ReturnType<typeof createVoiceChannelInfo>;
253+
234254
function createClient() {
235255
return {
236256
rest: {
237257
get: vi.fn(),
238258
},
239-
fetchChannel: vi.fn(async (channelId: string) => ({
240-
id: channelId,
241-
guildId: "g1",
242-
guild: { id: "g1", name: "Guild One" },
243-
type: ChannelType.GuildVoice,
244-
})),
259+
fetchChannel: vi.fn(
260+
async (channelId: string): Promise<VoiceChannelInfo | null> =>
261+
createVoiceChannelInfo(channelId),
262+
),
245263
fetchGuild: vi.fn(async (guildId: string) => ({
246264
id: guildId,
247265
name: "Guild One",

0 commit comments

Comments
 (0)