File tree Expand file tree Collapse file tree 1 file changed +32
-2
lines changed
Expand file tree Collapse file tree 1 file changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -460,12 +460,42 @@ describe("Mixer", () => {
460460 expect ( ( ) => mixer . stop ( ) ) . not . toThrow ( ) ;
461461 } ) ;
462462
463-
464-
465463 it ( "should pause playlist when stopping" , ( ) => {
466464 const mockPause = jest . fn ( ) ;
467465 mixer . playlist = { pause : mockPause } as unknown as Playlist ;
468466 mixer . stop ( ) ;
469467 expect ( mockPause ) . toHaveBeenCalled ( ) ;
470468 } ) ;
469+
470+ it ( "should call speaker engine play and stop methods" , async ( ) => {
471+ // Mock initContext to prevent it from overwriting our setup
472+ const originalInitContext = mixer . initContext ;
473+ mixer . initContext = jest . fn ( ) ;
474+
475+ // Mock the speaker engine methods
476+ const mockPlay = jest . fn ( ) ;
477+ const mockStop = jest . fn ( ) ;
478+
479+ // Create a proper speaker engine instance
480+ mixer . speakerEngine = new SpeakerEngine (
481+ mockClient . speakers ( ) ,
482+ mixer . audioContext ,
483+ { mode : "stream" }
484+ ) ;
485+
486+ // Spy on the methods
487+ jest . spyOn ( mixer . speakerEngine , "play" ) . mockImplementation ( mockPlay ) ;
488+ jest . spyOn ( mixer . speakerEngine , "stop" ) . mockImplementation ( mockStop ) ;
489+
490+ // Test play
491+ await mixer . play ( ) ;
492+ expect ( mockPlay ) . toHaveBeenCalled ( ) ;
493+
494+ // Test stop
495+ mixer . stop ( ) ;
496+ expect ( mockStop ) . toHaveBeenCalled ( ) ;
497+
498+ // Restore original initContext
499+ mixer . initContext = originalInitContext ;
500+ } ) ;
471501} ) ;
You can’t perform that action at this time.
0 commit comments