Skip to content

Commit 8aae969

Browse files
committed
Fix tests
1 parent 26ce545 commit 8aae969

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

Sources/StreamChat/Repositories/ConnectionRepository.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ConnectionRepository: @unchecked Sendable {
2626
private let syncRepository: SyncRepository
2727
private let webSocketRequestEncoder: RequestEncoder?
2828
private let webSocketClient: WebSocketClient?
29-
private var webSocketConnectEndpoint: Endpoint<EmptyResponse>?
29+
private(set) var webSocketConnectEndpoint: Endpoint<EmptyResponse>?
3030
private let apiClient: APIClient
3131
private let timerType: TimerScheduling.Type
3232

Tests/StreamChatTests/Repositories/ConnectionRepository_Tests.swift

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,15 @@ final class ConnectionRepository_Tests: XCTestCase {
204204

205205
repository.updateWebSocketEndpoint(with: token, userInfo: nil)
206206

207-
let expected = try apiClient.encoder.encodeRequest(for: .webSocketConnect(userInfo: UserInfo(id: tokenUserId)))
208-
209207
// UserInfo should take priority
210-
XCTAssertEqual(webSocketClient.connectRequest, expected)
208+
XCTAssertEqual(
209+
repository.webSocketConnectEndpoint.map(AnyEndpoint.init),
210+
AnyEndpoint(
211+
.webSocketConnect(
212+
userInfo: UserInfo(id: tokenUserId)
213+
)
214+
)
215+
)
211216
}
212217

213218
func test_updateWebSocketEndpointWithTokenAndUserInfo() throws {
@@ -218,20 +223,29 @@ final class ConnectionRepository_Tests: XCTestCase {
218223

219224
repository.updateWebSocketEndpoint(with: token, userInfo: userInfo)
220225

221-
let expected = try apiClient.encoder.encodeRequest(for: .webSocketConnect(userInfo: UserInfo(id: userInfoUserId)))
222-
223226
// UserInfo should take priority
224-
XCTAssertEqual(webSocketClient.connectRequest, expected)
227+
XCTAssertEqual(
228+
repository.webSocketConnectEndpoint.map(AnyEndpoint.init),
229+
AnyEndpoint(
230+
.webSocketConnect(
231+
userInfo: UserInfo(id: userInfoUserId)
232+
)
233+
)
234+
)
225235
}
226236

227237
func test_updateWebSocketEndpointWithUserId() throws {
228238
let userId = "123-userId"
229239
repository.updateWebSocketEndpoint(with: userId)
230240

231-
let expected = try apiClient.encoder.encodeRequest(for: .webSocketConnect(userInfo: UserInfo(id: userId)))
232-
233-
// UserInfo should take priority
234-
XCTAssertEqual(webSocketClient.connectRequest, expected)
241+
XCTAssertEqual(
242+
repository.webSocketConnectEndpoint.map(AnyEndpoint.init),
243+
AnyEndpoint(
244+
.webSocketConnect(
245+
userInfo: UserInfo(id: userId)
246+
)
247+
)
248+
)
235249
}
236250

237251
// MARK: Handle connection update

0 commit comments

Comments
 (0)