11/* eslint-disable @typescript-eslint/unbound-method */
22/* eslint-disable @typescript-eslint/dot-notation */
3- // @ts -nocheck
43import { EventEmitter } from 'node:events' ;
4+ import type { Mocked } from 'vitest' ;
55import { vitest , describe , test , expect , beforeEach } from 'vitest' ;
66import * as _DataStore from '../src/DataStore' ;
77import {
@@ -25,16 +25,16 @@ vitest.mock('../src/networking/Networking', async (importOriginal) => {
2525 // eslint-disable-next-line @typescript-eslint/consistent-type-imports
2626 const actual = await importOriginal < typeof import ( '../src/networking/Networking' ) > ( ) ;
2727 const Networking = actual . Networking ;
28- Networking . prototype . createWebSocket = vitest . fn ( ) ;
28+ Networking . prototype [ ' createWebSocket' ] = vitest . fn ( ) ;
2929 return {
3030 ...actual ,
3131 Networking,
3232 } ;
3333} ) ;
3434
35- const DataStore = _DataStore as unknown as vitest . Mocked < typeof _DataStore > ;
36- const AudioPlayer = _AudioPlayer as unknown as vitest . Mocked < typeof _AudioPlayer > ;
37- const PlayerSubscription = _PlayerSubscription as unknown as vitest . Mock < _PlayerSubscription > ;
35+ const DataStore = _DataStore as unknown as Mocked < typeof _DataStore > ;
36+ const AudioPlayer = _AudioPlayer as unknown as Mocked < typeof _AudioPlayer > ;
37+ const PlayerSubscription = _PlayerSubscription as unknown as Mocked < typeof _PlayerSubscription > ;
3838
3939const _NetworkingClass = Networking . Networking ;
4040vitest . spyOn ( Networking , 'Networking' ) . mockImplementation ( ( ...args ) => new _NetworkingClass ( ...args ) ) ;
@@ -133,9 +133,10 @@ describe('createVoiceConnection', () => {
133133
134134 const stateSetter = vitest . spyOn ( existingVoiceConnection , 'state' , 'set' ) ;
135135
136- // @ts -expect-error: We're testing
137136 DataStore . getVoiceConnection . mockImplementation ( ( guildId , group = 'default' ) =>
138- guildId === existingJoinConfig . guildId && group === existingJoinConfig . group ? existingVoiceConnection : null ,
137+ guildId === existingJoinConfig . guildId && group === existingJoinConfig . group
138+ ? existingVoiceConnection
139+ : undefined ,
139140 ) ;
140141
141142 const newAdapter = createFakeAdapter ( ) ;
@@ -172,9 +173,10 @@ describe('createVoiceConnection', () => {
172173
173174 const rejoinSpy = vitest . spyOn ( existingVoiceConnection , 'rejoin' ) ;
174175
175- // @ts -expect-error: We're testing
176176 DataStore . getVoiceConnection . mockImplementation ( ( guildId , group = 'default' ) =>
177- guildId === existingJoinConfig . guildId && group === existingJoinConfig . group ? existingVoiceConnection : null ,
177+ guildId === existingJoinConfig . guildId && group === existingJoinConfig . group
178+ ? existingVoiceConnection
179+ : undefined ,
178180 ) ;
179181
180182 const newAdapter = createFakeAdapter ( ) ;
@@ -204,9 +206,10 @@ describe('createVoiceConnection', () => {
204206 adapterCreator : existingAdapter . creator ,
205207 } ) ;
206208
207- // @ts -expect-error: We're testing
208209 DataStore . getVoiceConnection . mockImplementation ( ( guildId , group = 'default' ) =>
209- guildId === existingJoinConfig . guildId && group === existingJoinConfig . group ? existingVoiceConnection : null ,
210+ guildId === existingJoinConfig . guildId && group === existingJoinConfig . group
211+ ? existingVoiceConnection
212+ : undefined ,
210213 ) ;
211214
212215 const newAdapter = createFakeAdapter ( ) ;
@@ -444,7 +447,7 @@ describe('VoiceConnection#onNetworkingStateChange', () => {
444447 voiceConnection [ '_state' ] = {
445448 ...( voiceConnection . state as VoiceConnectionSignallingState ) ,
446449 status : VoiceConnectionStatus . Connecting ,
447- networking : new Networking . Networking ( { } as any , false ) ,
450+ networking : new Networking . Networking ( { } as any , { } ) ,
448451 } ;
449452
450453 voiceConnection [ 'onNetworkingStateChange' ] (
@@ -462,7 +465,7 @@ describe('VoiceConnection#onNetworkingStateChange', () => {
462465 voiceConnection [ '_state' ] = {
463466 ...( voiceConnection . state as VoiceConnectionSignallingState ) ,
464467 status : VoiceConnectionStatus . Connecting ,
465- networking : new Networking . Networking ( { } as any , false ) ,
468+ networking : new Networking . Networking ( { } as any , { } ) ,
466469 } ;
467470
468471 voiceConnection [ 'onNetworkingStateChange' ] (
@@ -492,7 +495,7 @@ describe('VoiceConnection#destroy', () => {
492495 voiceConnection . destroy ( ) ;
493496 expect ( DataStore . getVoiceConnection ) . toHaveReturnedWith ( voiceConnection ) ;
494497 expect ( DataStore . untrackVoiceConnection ) . toHaveBeenCalledWith ( voiceConnection ) ;
495- expect ( DataStore . createJoinVoiceChannelPayload . mock . calls [ 0 ] [ 0 ] ) . toMatchObject ( {
498+ expect ( DataStore . createJoinVoiceChannelPayload . mock . calls [ 0 ] ?. [ 0 ] ) . toMatchObject ( {
496499 channelId : null ,
497500 guildId : joinConfig . guildId ,
498501 } ) ;
@@ -518,7 +521,7 @@ describe('VoiceConnection#disconnect', () => {
518521 voiceConnection . state = {
519522 status : VoiceConnectionStatus . Ready ,
520523 adapter,
521- networking : new Networking . Networking ( { } as any , false ) ,
524+ networking : new Networking . Networking ( { } as any , { } ) ,
522525 } ;
523526 const leavePayload = Symbol ( 'dummy' ) ;
524527 DataStore . createJoinVoiceChannelPayload . mockImplementation ( ( ) => leavePayload as any ) ;
@@ -542,7 +545,7 @@ describe('VoiceConnection#disconnect', () => {
542545 voiceConnection . state = {
543546 status : VoiceConnectionStatus . Ready ,
544547 adapter,
545- networking : new Networking . Networking ( { } as any , false ) ,
548+ networking : new Networking . Networking ( { } as any , { } ) ,
546549 } ;
547550 adapter . sendPayload . mockImplementation ( ( ) => false ) ;
548551 expect ( voiceConnection . disconnect ( ) ) . toEqual ( false ) ;
@@ -676,7 +679,7 @@ describe('VoiceConnection#onSubscriptionRemoved', () => {
676679 // Arrange
677680 const ws = new EventEmitter ( ) as any ;
678681
679- const oldNetworking = new Networking . Networking ( { } as any , false ) ;
682+ const oldNetworking = new Networking . Networking ( { } as any , { } ) ;
680683 oldNetworking . state = {
681684 code : Networking . NetworkingStatusCode . Ready ,
682685 connectionData : { } as any ,
@@ -685,7 +688,7 @@ describe('VoiceConnection#onSubscriptionRemoved', () => {
685688 ws,
686689 } ;
687690
688- const newNetworking = new Networking . Networking ( { } as any , false ) ;
691+ const newNetworking = new Networking . Networking ( { } as any , { } ) ;
689692 newNetworking . state = {
690693 ...oldNetworking . state ,
691694 udp : new EventEmitter ( ) as any ,
@@ -706,7 +709,7 @@ describe('VoiceConnection#onSubscriptionRemoved', () => {
706709 // Arrange
707710 const udp = new EventEmitter ( ) as any ;
708711
709- const oldNetworking = new Networking . Networking ( { } as any , false ) ;
712+ const oldNetworking = new Networking . Networking ( { } as any , { } ) ;
710713 oldNetworking . state = {
711714 code : Networking . NetworkingStatusCode . Ready ,
712715 connectionData : { } as any ,
@@ -715,7 +718,7 @@ describe('VoiceConnection#onSubscriptionRemoved', () => {
715718 ws : new EventEmitter ( ) as any ,
716719 } ;
717720
718- const newNetworking = new Networking . Networking ( { } as any , false ) ;
721+ const newNetworking = new Networking . Networking ( { } as any , { } ) ;
719722 newNetworking . state = {
720723 ...oldNetworking . state ,
721724 ws : new EventEmitter ( ) as any ,
@@ -735,7 +738,7 @@ describe('VoiceConnection#onSubscriptionRemoved', () => {
735738 test ( 'Applies initial listeners' , ( ) => {
736739 // Arrange
737740
738- const newNetworking = new Networking . Networking ( { } as any , false ) ;
741+ const newNetworking = new Networking . Networking ( { } as any , { } ) ;
739742 newNetworking . state = {
740743 code : Networking . NetworkingStatusCode . Ready ,
741744 connectionData : { } as any ,
0 commit comments