mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Add tests for the UserSessionStore. (#6065)
* Add enough mock configurations to test the UserSessionStore. * Add tests for the UserSessionStore.
This commit is contained in:
@@ -59,5 +59,13 @@ extension ClientFactoryMock {
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
makeAppClientCredentialsClientSessionDelegateAppSettingsAppHooksClosure = { credentials, _, _, _ in
|
||||
ClientSDKMock(.init(userID: credentials.userID))
|
||||
}
|
||||
|
||||
makeNSEClientCredentialsRoomIDClientSessionDelegateAppSettingsAppHooksClosure = { credentials, _, _, _, _ in
|
||||
ClientSDKMock(.init(userID: credentials.userID))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,6 @@ nonisolated extension ClientBuilderSDKMock {
|
||||
convenience init(_ configuration: Configuration) {
|
||||
self.init()
|
||||
|
||||
disableWellKnownLookupDisableWellKnownLookupReturnValue = self
|
||||
disableWellKnownLookupDisableWellKnownLookupClosure = { [unowned self] _ in self }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +68,22 @@ nonisolated extension ClientSDKMock {
|
||||
throw MockError.generic
|
||||
}
|
||||
}
|
||||
|
||||
encryptionReturnValue = EncryptionSDKMock(.init())
|
||||
getNotificationSettingsReturnValue = NotificationSettingsSDKMock()
|
||||
homeserverCapabilitiesReturnValue = HomeserverCapabilitiesSDKMock()
|
||||
spaceServiceReturnValue = SpaceServiceSDKMock(.init())
|
||||
searchServiceReturnValue = SearchServiceSDKMock(.init())
|
||||
syncServiceReturnValue = SyncServiceBuilderSDKMock(.init())
|
||||
|
||||
setDelegateDelegateReturnValue = TaskHandleSDKMock()
|
||||
subscribeToIgnoredUsersListenerReturnValue = TaskHandleSDKMock()
|
||||
subscribeToSendQueueStatusListenerReturnValue = TaskHandleSDKMock()
|
||||
subscribeToSendQueueUpdatesListenerReturnValue = TaskHandleSDKMock()
|
||||
subscribeToMediaPreviewConfigListenerReturnValue = TaskHandleSDKMock()
|
||||
subscribeToOwnBeaconInfoUpdatesListenerReturnValue = TaskHandleSDKMock()
|
||||
isProfilesSlidingSyncExtensionSupportedReturnValue = false
|
||||
isUserStatusSupportedReturnValue = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Copyright 2026 Element Creations Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
import MatrixRustSDKMocks
|
||||
|
||||
nonisolated extension EncryptionSDKMock {
|
||||
struct Configuration {
|
||||
var verificationState: VerificationState = .unknown
|
||||
}
|
||||
|
||||
convenience init(_ configuration: Configuration) {
|
||||
self.init()
|
||||
|
||||
verificationStateReturnValue = configuration.verificationState
|
||||
backupStateListenerListenerReturnValue = TaskHandleSDKMock()
|
||||
recoveryStateListenerListenerReturnValue = TaskHandleSDKMock()
|
||||
verificationStateListenerListenerReturnValue = TaskHandleSDKMock()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Copyright 2026 Element Creations Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
import MatrixRustSDKMocks
|
||||
|
||||
nonisolated extension RoomListSDKMock {
|
||||
struct Configuration {
|
||||
var loadingState: RoomListLoadingState = .notLoaded
|
||||
}
|
||||
|
||||
convenience init(_ configuration: Configuration) {
|
||||
self.init()
|
||||
|
||||
let dynamicAdapters = RoomListEntriesWithDynamicAdaptersResultSDKMock()
|
||||
let entriesController = RoomListDynamicEntriesControllerSDKMock()
|
||||
entriesController.setFilterKindReturnValue = true
|
||||
dynamicAdapters.controllerReturnValue = entriesController
|
||||
|
||||
entriesWithDynamicAdaptersPageSizeListenerReturnValue = dynamicAdapters
|
||||
loadingStateListenerReturnValue = .init(state: configuration.loadingState, stateStream: TaskHandleSDKMock())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// Copyright 2026 Element Creations Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
import MatrixRustSDKMocks
|
||||
|
||||
nonisolated extension RoomListServiceSDKMock {
|
||||
struct Configuration {
|
||||
var roomList = RoomListSDKMock(.init())
|
||||
}
|
||||
|
||||
convenience init(_ configuration: Configuration) {
|
||||
self.init()
|
||||
|
||||
allRoomsReturnValue = configuration.roomList
|
||||
stateListenerReturnValue = TaskHandleSDKMock()
|
||||
syncIndicatorDelayBeforeShowingInMsDelayBeforeHidingInMsListenerReturnValue = TaskHandleSDKMock()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Copyright 2026 Element Creations Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
import MatrixRustSDKMocks
|
||||
|
||||
nonisolated extension SearchServiceSDKMock {
|
||||
struct Configuration { }
|
||||
|
||||
convenience init(_ configuration: Configuration) {
|
||||
self.init()
|
||||
|
||||
paginationStateReturnValue = .idle(endReached: true)
|
||||
subscribeToPaginationStateUpdatesListenerReturnValue = TaskHandleSDKMock()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Copyright 2026 Element Creations Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
import MatrixRustSDKMocks
|
||||
|
||||
nonisolated extension SpaceServiceSDKMock {
|
||||
struct Configuration { }
|
||||
|
||||
convenience init(_ configuration: Configuration) {
|
||||
self.init()
|
||||
|
||||
subscribeToTopLevelJoinedSpacesListenerReturnValue = TaskHandleSDKMock()
|
||||
subscribeToSpaceFiltersListenerReturnValue = TaskHandleSDKMock()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Copyright 2026 Element Creations Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
import MatrixRustSDKMocks
|
||||
|
||||
nonisolated extension SyncServiceBuilderSDKMock {
|
||||
struct Configuration {
|
||||
var syncService = SyncServiceSDKMock(.init())
|
||||
}
|
||||
|
||||
convenience init(_ configuration: Configuration) {
|
||||
self.init()
|
||||
|
||||
withOfflineModeClosure = { [unowned self] in self }
|
||||
withSharePosEnableClosure = { [unowned self] _ in self }
|
||||
withProfilesExtensionClosure = { [unowned self] in self }
|
||||
finishReturnValue = configuration.syncService
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// Copyright 2026 Element Creations Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
import MatrixRustSDKMocks
|
||||
|
||||
nonisolated extension SyncServiceSDKMock {
|
||||
struct Configuration {
|
||||
var roomListService = RoomListServiceSDKMock(.init())
|
||||
}
|
||||
|
||||
convenience init(_ configuration: Configuration) {
|
||||
self.init()
|
||||
|
||||
roomListServiceReturnValue = configuration.roomListService
|
||||
stateListenerReturnValue = TaskHandleSDKMock()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user