@@ -9,6 +9,7 @@ import { DailyAudio } from '../../src/components/DailyAudio';
99import { DailyProvider } from '../../src/DailyProvider' ;
1010import {
1111 emitActiveSpeakerChange ,
12+ emitJoinedMeeting ,
1213 emitParticipantLeft ,
1314 emitParticipantUpdated ,
1415 emitStartedCamera ,
@@ -365,46 +366,44 @@ describe('DailyAudio', () => {
365366 faker . datatype . uuid ( ) ,
366367 faker . datatype . uuid ( ) ,
367368 ] ;
368- ( callObject . participants as jest . Mock ) . mockImplementation ( ( ) => {
369- const participants : Record < string , Partial < DailyParticipant > > = {
370- local : mockParticipant ( {
371- local : true ,
372- session_id : localSessionId ,
373- } ) ,
374- } ;
375- remoteParticipants . forEach ( ( id ) => {
376- const peer = mockParticipant ( {
377- local : false ,
378- session_id : id ,
379- } ) ;
380- peer . tracks . audio . state = 'playable' ;
381- peer . tracks . audio . subscribed = true ;
382- participants [ id ] = peer ;
369+ const participants : Record < string , Partial < DailyParticipant > > = {
370+ local : mockParticipant ( {
371+ local : true ,
372+ session_id : localSessionId ,
373+ } ) ,
374+ } ;
375+ remoteParticipants . forEach ( ( id ) => {
376+ const peer = mockParticipant ( {
377+ local : false ,
378+ session_id : id ,
383379 } ) ;
384- return participants ;
380+ peer . tracks . audio . state = 'playable' ;
381+ peer . tracks . audio . subscribed = true ;
382+ participants [ id ] = peer ;
385383 } ) ;
384+ ( callObject . participants as jest . Mock ) . mockImplementation (
385+ ( ) => participants
386+ ) ;
386387 const Wrapper = createWrapper ( callObject ) ;
387388 const { container } = render (
388389 < Wrapper >
389390 < DailyAudio maxSpeakers = { 3 } />
390391 </ Wrapper >
391392 ) ;
392- jest . useFakeTimers ( ) ;
393+ act ( ( ) => emitJoinedMeeting ( callObject , participants ) ) ;
393394 act ( ( ) => emitStartedCamera ( callObject ) ) ;
394395 act ( ( ) => emitActiveSpeakerChange ( callObject , remoteParticipants [ 0 ] ) ) ;
395- await waitFor ( ( ) =>
396- expect ( queryAudioById ( remoteParticipants [ 0 ] , container ) ) . not . toBeNull ( )
397- ) ;
396+ await waitFor ( ( ) => {
397+ expect ( queryAudioById ( remoteParticipants [ 0 ] , container ) ) . not . toBeNull ( ) ;
398+ } ) ;
398399 act ( ( ) => {
399- jest . advanceTimersByTime ( 5000 ) ;
400400 emitActiveSpeakerChange ( callObject , remoteParticipants [ 1 ] ) ;
401401 } ) ;
402402 await waitFor ( ( ) => {
403403 expect ( queryAudioById ( remoteParticipants [ 0 ] , container ) ) . not . toBeNull ( ) ;
404404 expect ( queryAudioById ( remoteParticipants [ 1 ] , container ) ) . not . toBeNull ( ) ;
405405 } ) ;
406406 act ( ( ) => {
407- jest . advanceTimersByTime ( 5000 ) ;
408407 emitActiveSpeakerChange ( callObject , remoteParticipants [ 2 ] ) ;
409408 } ) ;
410409 await waitFor ( ( ) => {
@@ -413,7 +412,6 @@ describe('DailyAudio', () => {
413412 expect ( queryAudioById ( remoteParticipants [ 2 ] , container ) ) . not . toBeNull ( ) ;
414413 } ) ;
415414 act ( ( ) => {
416- jest . advanceTimersByTime ( 5000 ) ;
417415 emitActiveSpeakerChange ( callObject , remoteParticipants [ 3 ] ) ;
418416 } ) ;
419417 await waitFor ( ( ) => {
@@ -422,7 +420,6 @@ describe('DailyAudio', () => {
422420 expect ( queryAudioById ( remoteParticipants [ 2 ] , container ) ) . not . toBeNull ( ) ;
423421 expect ( queryAudioById ( remoteParticipants [ 3 ] , container ) ) . not . toBeNull ( ) ;
424422 } ) ;
425- jest . useRealTimers ( ) ;
426423 } ) ;
427424 } ) ;
428425} ) ;
0 commit comments