@@ -406,6 +406,22 @@ final class SFUEventAdapter_Tests: XCTestCase, @unchecked Sendable {
406406 }
407407 }
408408
409+ func test_handleTrackPublished_givenAudioEvent_participantDoesNotExist_whenPublished_thenAddsAndUpdatesParticipantAudioStatus(
410+ ) async throws {
411+ let participant = CallParticipant . dummy ( )
412+ var event = Stream_Video_Sfu_Event_TrackPublished ( )
413+ event. sessionID = participant. sessionId
414+ event. type = . audio
415+
416+ try await assert (
417+ event,
418+ wrappedEvent: . sfuEvent( . trackPublished( event) ) ,
419+ initialState: [ : ]
420+ ) {
421+ $0. count == 1 && $0 [ participant. sessionId] ? . hasAudio == true
422+ }
423+ }
424+
409425 // MARK: trackUnpublished
410426
411427 func test_handleTrackUnpublished_givenAudioEvent_whenPublished_thenUpdatesParticipantAudioStatus( ) async throws {
@@ -507,6 +523,22 @@ final class SFUEventAdapter_Tests: XCTestCase, @unchecked Sendable {
507523 }
508524 }
509525
526+ func test_handleTrackUnpublished_givenAudioEvent_participantDoesNotExist_whenPublished_thenAddsAndUpdatesParticipantAudioStatus(
527+ ) async throws {
528+ let participant = CallParticipant . dummy ( hasAudio: true )
529+ var event = Stream_Video_Sfu_Event_TrackUnpublished ( )
530+ event. sessionID = participant. sessionId
531+ event. type = . audio
532+
533+ try await assert (
534+ event,
535+ wrappedEvent: . sfuEvent( . trackUnpublished( event) ) ,
536+ initialState: [ : ]
537+ ) {
538+ $0. count == 1 && $0 [ participant. sessionId] ? . hasAudio == false
539+ }
540+ }
541+
510542 // MARK: pinsChanged
511543
512544 func test_handlePinsChanged_givenEvent_whenPublished_thenUpdatesPinnedParticipants( ) async throws {
@@ -587,6 +619,23 @@ final class SFUEventAdapter_Tests: XCTestCase, @unchecked Sendable {
587619 }
588620 }
589621
622+ func test_handleParticipantUpdated_givenEvent_participantDoesNotExist_whenPublished_thenUAddsAndpdatesParticipant(
623+ ) async throws {
624+ var event = Stream_Video_Sfu_Event_ParticipantUpdated ( )
625+ // We add the showTrack and audioLevels to match what the `event.participant.toCallParticipant()`
626+ // does (defaults to showTrack:True and uses the audioLevel to create an array for the audioLevels.)
627+ let expectedParticipant = CallParticipant . dummy ( showTrack: true , audioLevels: [ 0 ] )
628+ event. participant = . init( expectedParticipant)
629+
630+ try await assert (
631+ event,
632+ wrappedEvent: . sfuEvent( . participantUpdated( event) ) ,
633+ initialState: [ : ]
634+ ) {
635+ $0. count == 1 && $0 [ expectedParticipant. sessionId] == expectedParticipant
636+ }
637+ }
638+
590639 // MARK: publishOptionsChanged
591640
592641 func test_handleChangePublishOptions_givenEvent_whenPublished_thenUpdatesPublishOptions( ) async throws {
0 commit comments