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>
This commit is contained in:
pat
2024-10-07 01:26:53 +11:00
committed by GitHub
parent bb04e09f8b
commit 24128a3c45
21 changed files with 267 additions and 219 deletions

View File

@@ -1,5 +1,6 @@
import { EventEmitter } from 'node:events';
import process from 'node:process';
import { describe, test, expect, vitest, beforeEach } from 'vitest';
import { VoiceConnectionStatus, type VoiceConnection } from '../src/VoiceConnection';
import { entersState } from '../src/util/entersState';
@@ -10,12 +11,12 @@ function createFakeVoiceConnection(status = VoiceConnectionStatus.Signalling) {
}
beforeEach(() => {
jest.useFakeTimers();
vitest.useFakeTimers();
});
describe('entersState', () => {
test('Returns the target once the state has been entered before timeout', async () => {
jest.useRealTimers();
vitest.useRealTimers();
const vc = createFakeVoiceConnection();
process.nextTick(() => vc.emit(VoiceConnectionStatus.Ready, null as any, null as any));
const result = await entersState(vc, VoiceConnectionStatus.Ready, 1_000);
@@ -25,12 +26,12 @@ describe('entersState', () => {
test('Rejects once the timeout is exceeded', async () => {
const vc = createFakeVoiceConnection();
const promise = entersState(vc, VoiceConnectionStatus.Ready, 1_000);
jest.runAllTimers();
vitest.runAllTimers();
await expect(promise).rejects.toThrowError();
});
test('Returns the target once the state has been entered before signal is aborted', async () => {
jest.useRealTimers();
vitest.useRealTimers();
const vc = createFakeVoiceConnection();
const ac = new AbortController();
process.nextTick(() => vc.emit(VoiceConnectionStatus.Ready, null as any, null as any));