mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 16:24:11 +00:00
Switch to using proper SDK Mocks everywhere.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
import Combine
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
import MatrixRustSDKMocks
|
||||
|
||||
struct TimelineControllerMockConfiguration {
|
||||
var roomProxy: JoinedRoomProxyProtocol?
|
||||
@@ -204,7 +205,7 @@ extension TimelineControllerMock {
|
||||
return .success(())
|
||||
}
|
||||
|
||||
messageEventContentForReturnValue = .init(noHandle: .init())
|
||||
messageEventContentForReturnValue = RoomMessageEventContentWithoutRelationSDKMock()
|
||||
debugInfoForReturnValue = .init(model: "Mock debug description", originalJSON: nil, latestEditJSON: nil)
|
||||
|
||||
eventTimestampForClosure = { [timelineItemsTimestamps] itemID in
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
import Combine
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
import MatrixRustSDKMocks
|
||||
|
||||
extension TimelineProxyMock {
|
||||
struct Configuration {
|
||||
@@ -24,7 +25,7 @@ extension TimelineProxyMock {
|
||||
sendMessageEventContentReturnValue = .success(())
|
||||
sendMessageHtmlInReplyToEventIDIntentionalMentionsReturnValue = .success(())
|
||||
editNewContentReturnValue = .success(())
|
||||
buildMessageContentForHtmlIntentionalMentionsReturnValue = RoomMessageEventContentWithoutRelation(noHandle: .init())
|
||||
buildMessageContentForHtmlIntentionalMentionsReturnValue = RoomMessageEventContentWithoutRelationSDKMock()
|
||||
paginateBackwardsRequestSizeReturnValue = .success(())
|
||||
paginateForwardsRequestSizeReturnValue = .success(())
|
||||
sendReadReceiptForTypeReturnValue = .success(())
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
import Compound
|
||||
import MatrixRustSDKMocks
|
||||
import SwiftUI
|
||||
|
||||
struct MessageForwardingScreen: View {
|
||||
@@ -97,7 +98,7 @@ struct MessageForwardingScreen_Previews: PreviewProvider, TestablePreview {
|
||||
let summaryProvider = RoomSummaryProviderMock(.init(state: .loaded(.mockRooms)))
|
||||
let viewModel = MessageForwardingScreenViewModel(forwardingItem: .init(id: .randomEvent,
|
||||
roomID: "",
|
||||
content: .init(noHandle: .init())),
|
||||
content: RoomMessageEventContentWithoutRelationSDKMock()),
|
||||
userSession: UserSessionMock(.init()),
|
||||
roomSummaryProvider: summaryProvider,
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
import MatrixRustSDKMocks
|
||||
|
||||
/// A light wrapper around timeline items returned from Rust.
|
||||
enum TimelineItemProxy {
|
||||
@@ -204,7 +205,7 @@ struct SendHandleProxy: Hashable {
|
||||
static var mock: SendHandleProxy {
|
||||
.init(itemID: .event(uniqueID: .init(UUID().uuidString),
|
||||
eventOrTransactionID: .eventID(UUID().uuidString)),
|
||||
underlyingHandle: .init(noHandle: .init()))
|
||||
underlyingHandle: SendHandleSDKMock())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
import Combine
|
||||
import MatrixRustSDK
|
||||
import MatrixRustSDKMocks
|
||||
import SwiftUI
|
||||
import UIKit
|
||||
|
||||
@@ -876,7 +877,7 @@ class MockScreen: Identifiable {
|
||||
|
||||
timelineProxy.buildMessageContentForHtmlIntentionalMentionsClosure = { text, _, _ in
|
||||
pendingEditText = text
|
||||
return RoomMessageEventContentWithoutRelation(noHandle: .init())
|
||||
return RoomMessageEventContentWithoutRelationSDKMock()
|
||||
}
|
||||
|
||||
timelineProxy.editNewContentClosure = { [weak itemProvider] _, _ in
|
||||
|
||||
@@ -147,7 +147,7 @@ struct AuthenticationServiceTests {
|
||||
|
||||
let classicAppManager = ClassicAppManagerMock(.init(accounts: classicAppAccounts,
|
||||
availableSecrets: availableSecrets,
|
||||
secretsBundle: .init(noHandle: .init())))
|
||||
secretsBundle: SecretsBundleWithUserIdSDKMock()))
|
||||
|
||||
service = AuthenticationService(userSessionStore: userSessionStore,
|
||||
encryptionKeyProvider: encryptionKeyProvider,
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
import Combine
|
||||
@testable import ElementX
|
||||
import MatrixRustSDKMocks
|
||||
import Testing
|
||||
|
||||
@MainActor
|
||||
@@ -21,7 +22,7 @@ struct HomeScreenRoomTests {
|
||||
notificationMode: RoomNotificationModeProxy,
|
||||
hasOngoingCall: Bool,
|
||||
activeCallIntent: CallIntent? = nil) {
|
||||
roomSummary = RoomSummary(room: .init(noHandle: .init()),
|
||||
roomSummary = RoomSummary(room: RoomSDKMock(),
|
||||
id: "Test room",
|
||||
joinRequestType: nil,
|
||||
name: "Test room",
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
@testable import ElementX
|
||||
import Foundation
|
||||
@testable import MatrixRustSDK
|
||||
import MatrixRustSDKMocks
|
||||
import Testing
|
||||
|
||||
final class LoggingTests {
|
||||
@@ -72,7 +73,7 @@ final class LoggingTests {
|
||||
let roomName = "Private Conversation"
|
||||
let lastMessage = "Secret information"
|
||||
let heroName = "Pseudonym"
|
||||
let roomSummary = RoomSummary(room: .init(noHandle: .init()),
|
||||
let roomSummary = RoomSummary(room: RoomSDKMock(),
|
||||
id: "myroomid",
|
||||
joinRequestType: nil,
|
||||
name: roomName,
|
||||
@@ -223,19 +224,19 @@ final class LoggingTests {
|
||||
let rustImageMessage = ImageMessageContent(filename: "ImageString",
|
||||
caption: "ImageString",
|
||||
formattedCaption: nil,
|
||||
source: MediaSource(noHandle: .init()),
|
||||
source: MediaSourceSDKMock(),
|
||||
info: nil)
|
||||
|
||||
let rustVideoMessage = VideoMessageContent(filename: "VideoString",
|
||||
caption: "VideoString",
|
||||
formattedCaption: nil,
|
||||
source: MediaSource(noHandle: .init()),
|
||||
source: MediaSourceSDKMock(),
|
||||
info: nil)
|
||||
|
||||
let rustFileMessage = FileMessageContent(filename: "FileString",
|
||||
caption: "FileString",
|
||||
formattedCaption: nil,
|
||||
source: MediaSource(noHandle: .init()),
|
||||
source: MediaSourceSDKMock(),
|
||||
info: nil)
|
||||
|
||||
// When logging that value
|
||||
|
||||
@@ -8,13 +8,14 @@
|
||||
|
||||
import Combine
|
||||
@testable import ElementX
|
||||
import MatrixRustSDKMocks
|
||||
import Testing
|
||||
|
||||
@MainActor
|
||||
struct MessageForwardingScreenViewModelTests {
|
||||
let forwardingItem = MessageForwardingItem(id: .event(uniqueID: .init("t1"), eventOrTransactionID: .eventID("t1")),
|
||||
roomID: "1",
|
||||
content: .init(noHandle: .init()))
|
||||
content: RoomMessageEventContentWithoutRelationSDKMock())
|
||||
var viewModel: MessageForwardingScreenViewModelProtocol!
|
||||
var context: MessageForwardingScreenViewModelType.Context!
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ final class RoomSummaryProviderTests {
|
||||
dynamicAdaptersResult.controllerReturnValue = dynamicEntriesController
|
||||
roomList = RoomListSDKMock()
|
||||
roomList.entriesWithDynamicAdaptersPageSizeListenerReturnValue = dynamicAdaptersResult
|
||||
roomList.loadingStateListenerReturnValue = .some(.init(state: .notLoaded, stateStream: .init(noHandle: .init())))
|
||||
roomList.loadingStateListenerReturnValue = .some(.init(state: .notLoaded, stateStream: TaskHandleSDKMock()))
|
||||
roomSummaryProvider.setRoomList(roomList)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
@testable import ElementX
|
||||
import Foundation
|
||||
import MatrixRustSDKMocks
|
||||
import Testing
|
||||
|
||||
struct RoomSummaryTests {
|
||||
@@ -95,7 +96,7 @@ struct RoomSummaryTests {
|
||||
// MARK: - Helpers
|
||||
|
||||
func makeSummary(isDirect: Bool, isSpace: Bool, hasRoomAvatar: Bool, isTombstoned: Bool) -> RoomSummary {
|
||||
RoomSummary(room: .init(noHandle: .init()),
|
||||
RoomSummary(room: RoomSDKMock(),
|
||||
id: roomDetails.id,
|
||||
joinRequestType: nil,
|
||||
name: roomDetails.name,
|
||||
|
||||
Reference in New Issue
Block a user