User sessions tests (#390)

* User sessions tests

* Refactor

- Merge SessionVerificationControllerProxyMock into MockSessionVerificationControllerProxy.
- Merge ClientProxyMock into MockClientProxy.
- Simplify naming.

Co-authored-by: Doug <douglase@element.io>
This commit is contained in:
Aleksandrs Proskurins
2023-01-06 12:53:19 +02:00
committed by GitHub
parent 34eb835a0b
commit bf9b82334d
7 changed files with 185 additions and 175 deletions
@@ -79,14 +79,31 @@ class MockClientProxy: ClientProxyProtocol {
throw ClientProxyError.failedLoadingMedia
}
var sessionVerificationControllerProxyResult: Result<SessionVerificationControllerProxyProtocol, ClientProxyError>?
func sessionVerificationControllerProxy() async -> Result<SessionVerificationControllerProxyProtocol, ClientProxyError> {
.failure(.failedRetrievingSessionVerificationController)
if let sessionVerificationControllerProxyResult {
return sessionVerificationControllerProxyResult
} else {
return .failure(.failedRetrievingSessionVerificationController)
}
}
func logout() async {
// no-op
}
var setPusherCalled = false
var setPusherErrorToThrow: Error?
var setPusherPushkey: String?
var setPusherKind: PusherKind?
var setPusherAppId: String?
var setPusherAppDisplayName: String?
var setPusherDeviceDisplayName: String?
var setPusherProfileTag: String?
var setPusherLang: String?
var setPusherUrl: String?
var setPusherFormat: PushFormat?
var setPusherDefaultPayload: [AnyHashable: Any]?
// swiftlint:disable:next function_parameter_count
func setPusher(pushkey: String,
kind: PusherKind?,
@@ -98,6 +115,17 @@ class MockClientProxy: ClientProxyProtocol {
url: String?,
format: PushFormat?,
defaultPayload: [AnyHashable: Any]?) async throws {
// no-op
if let setPusherErrorToThrow { throw setPusherErrorToThrow }
setPusherCalled = true
setPusherPushkey = pushkey
setPusherKind = kind
setPusherAppId = appId
setPusherAppDisplayName = appDisplayName
setPusherDeviceDisplayName = deviceDisplayName
setPusherProfileTag = profileTag
setPusherLang = lang
setPusherUrl = url
setPusherFormat = format
setPusherDefaultPayload = defaultPayload
}
}