2
2
// Copyright © 2025 Stream.io Inc. All rights reserved.
3
3
//
4
4
5
- #if swift(>=6.0)
6
5
@testable import StreamVideo
7
6
@testable import StreamVideoSwiftUI
8
7
import StreamWebRTC
@@ -32,9 +31,7 @@ final class CallViewModel_Tests: XCTestCase, @unchecked Sendable {
32
31
thirdUser = nil
33
32
secondUser = nil
34
33
firstUser = nil
35
- mockResponseBuilder = nil
36
- peerConnectionFactory = nil
37
- super. tearDown ( )
34
+ try await super. tearDown ( )
38
35
}
39
36
40
37
@MainActor
@@ -554,6 +551,46 @@ final class CallViewModel_Tests: XCTestCase, @unchecked Sendable {
554
551
await fulfilmentInMainActor { self . subject. participantEvent == nil }
555
552
}
556
553
554
+ func test_inCall_ringingCallEnds_activeCallRemainsJoined( ) async throws {
555
+ // Given
556
+ await prepare ( )
557
+ subject. startCall ( callType: callType, callId: callId, members: participants)
558
+ await assertCallingState ( . inCall)
559
+
560
+ let newCallId = String . unique
561
+ let cid = callCid ( from: newCallId, callType: . default)
562
+ // When
563
+ streamVideo. process (
564
+ . coordinatorEvent(
565
+ . typeCallRingEvent(
566
+ . init(
567
+ call: . dummy( cid: cid) ,
568
+ callCid: cid,
569
+ createdAt: . init( ) ,
570
+ members: [ ] ,
571
+ sessionId: . unique,
572
+ user: . dummy( ) ,
573
+ video: true
574
+ )
575
+ )
576
+ )
577
+ )
578
+ streamVideo. process (
579
+ . coordinatorEvent(
580
+ . typeCallEndedEvent(
581
+ . init(
582
+ call: . dummy( cid: cid) ,
583
+ callCid: cid,
584
+ createdAt: . init( )
585
+ )
586
+ )
587
+ )
588
+ )
589
+
590
+ // Then
591
+ await assertCallingState ( . inCall)
592
+ }
593
+
557
594
func test_inCall_participantJoinedAndLeft( ) async throws {
558
595
// Given
559
596
await prepare ( )
@@ -968,9 +1005,6 @@ final class CallViewModel_Tests: XCTestCase, @unchecked Sendable {
968
1005
streamVideo. state. user = firstUser. user
969
1006
970
1007
subject = . init( )
971
- await fulfilmentInMainActor ( file: file, line: line) {
972
- self . subject. isSubscribedToCallEvents
973
- }
974
1008
}
975
1009
976
1010
private func prepareIncomingCallScenario(
@@ -1110,11 +1144,18 @@ final class CallViewModel_Tests: XCTestCase, @unchecked Sendable {
1110
1144
if let delay {
1111
1145
await wait ( for: delay)
1112
1146
}
1147
+ #if compiler(>=6.0)
1113
1148
await fulfilmentInMainActor (
1114
1149
" CallViewModel.callingState expected: \( expected) actual: \( subject. callingState) " ,
1115
1150
file: file,
1116
1151
line: line
1117
1152
) { self . subject. callingState == expected }
1153
+ #else
1154
+ await fulfilmentInMainActor (
1155
+ file: file,
1156
+ line: line
1157
+ ) { self . subject. callingState == expected }
1158
+ #endif
1118
1159
}
1119
1160
}
1120
1161
@@ -1138,4 +1179,3 @@ extension User {
1138
1179
extension Member {
1139
1180
var userId : String { id }
1140
1181
}
1141
- #endif
0 commit comments