-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathOutgoingRingingController_Tests.swift
More file actions
76 lines (60 loc) · 2.24 KB
/
OutgoingRingingController_Tests.swift
File metadata and controls
76 lines (60 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//
// Copyright © 2026 Stream.io Inc. All rights reserved.
//
@testable import StreamVideo
@preconcurrency import XCTest
final class OutgoingRingingController_Tests: StreamVideoTestCase, @unchecked Sendable {
private lazy var applicationStateAdapter: MockAppStateAdapter! = .init()
private lazy var callType: String! = .default
private lazy var callId: String! = .unique
private lazy var otherCallId: String! = .unique
private var subject: OutgoingRingingController!
// MARK: - Lifecycle
override func setUp() {
super.setUp()
applicationStateAdapter.makeShared()
}
override func tearDown() {
applicationStateAdapter.dismante()
subject = nil
otherCallId = nil
callId = nil
callType = nil
applicationStateAdapter = nil
super.tearDown()
}
// MARK: - init
func test_matchingRingingCall_onBackground_handlerIsCalled() async {
let call = streamVideo.call(callType: callType, callId: callId)
let handlerWasCalled = expectation(description: "Handler was called.")
subject = makeSubject(for: call) {
handlerWasCalled.fulfill()
}
streamVideo.state.ringingCall = call
applicationStateAdapter.stubbedState = .background
await fulfillment(of: [handlerWasCalled])
}
func test_nonMatchingRingingCall_onBackground_handlerIsNotCalled() async {
let call = streamVideo.call(callType: callType, callId: callId)
let otherCall = streamVideo.call(callType: callType, callId: otherCallId)
let handlerWasCalled = expectation(description: "Handler was called.")
handlerWasCalled.isInverted = true
subject = makeSubject(for: call) {
handlerWasCalled.fulfill()
}
streamVideo.state.ringingCall = otherCall
applicationStateAdapter.stubbedState = .background
await fulfillment(of: [handlerWasCalled], timeout: 0.2)
}
// MARK: - Private Helpers
private func makeSubject(
for call: Call,
handler: @escaping () async throws -> Void
) -> OutgoingRingingController {
.init(
streamVideo: streamVideo,
callCiD: call.cId,
handler: handler
)
}
}