Files
discord.js/packages/voice/__tests__/joinVoiceChannel.test.ts
pat 24128a3c45 test: replace jest with vitest (#10472)
* chore: vitest config

* feat: vitest

* fix: do not actually create ws

* chore: config

* chore: lockfile

* chore: revert downgrade, up node

* chore: package - 'git add -A'

* chore: delete mock-socket

* chore: delete mock-socket

* fix: lockfile

---------

Co-authored-by: almeidx <github@almeidx.dev>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-10-06 14:26:53 +00:00

45 lines
1.1 KiB
TypeScript

// @ts-nocheck
import { describe, test, expect, vitest, beforeAll, beforeEach } from 'vitest';
import * as VoiceConnection from '../src/VoiceConnection';
import { joinVoiceChannel } from '../src/joinVoiceChannel';
const adapterCreator = () => ({ destroy: vitest.fn(), send: vitest.fn() }) as any;
const createVoiceConnection = vitest.spyOn(VoiceConnection, 'createVoiceConnection');
beforeAll(() => {
createVoiceConnection.mockImplementation(() => null as any);
});
beforeEach(() => {
createVoiceConnection.mockClear();
});
describe('joinVoiceChannel', () => {
test('Uses default group', () => {
joinVoiceChannel({
channelId: '123',
guildId: '456',
adapterCreator,
});
expect(createVoiceConnection.mock.calls[0][0]).toMatchObject({
channelId: '123',
guildId: '456',
group: 'default',
});
});
test('Respects custom group', () => {
joinVoiceChannel({
channelId: '123',
guildId: '456',
group: 'abc',
adapterCreator,
});
expect(createVoiceConnection.mock.calls[0][0]).toMatchObject({
channelId: '123',
guildId: '456',
group: 'abc',
});
});
});