mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Extract composer toolbar to a dedicated component (#1427)
* Extract composer toolbar to a dedicated component * Use publisher for composer mode * Introduce `RoomScreenComposerProvider` * Add `ComposerToolbarViewModelTests` * Rename protocols and add passthrough subjects for focused and composer mode * Remove `ComposerToolbarViewActionHandler` and `ComposerToolbarCoordinatorParameters` * Remove `RoomScreenComposerActionHandlerProtocol` and `RoomScreenComposerProviderProtocol` * Re-arrange code a bit * Remove composer mode being stored on `RoomScreen` * Rename `process(viewAction: ComposerToolbarViewAction)` to `process(composerAction: ComposerToolbarViewAction)` * Replace PassthroughSubject with direct function call * Remove `ComposerToolbarCoordinator` * Remove `cancelEdit` and `cancelReply` from external composer view model actions * Use `RoomScreenComposerAction` as a sub-`RoomScreenViewModelAction` * Move `ComposerToolbarViewModel` callback to actionsSubject * Move `RoomScreenViewModel` callback to actionsSubject * Fix `RoomScreenViewModelTests` * Rename `composerAction` parameter to `roomAction` * Fix unit tests
This commit is contained in:
@@ -15,11 +15,14 @@
|
||||
//
|
||||
|
||||
@testable import ElementX
|
||||
|
||||
import Combine
|
||||
import XCTest
|
||||
|
||||
@MainActor
|
||||
class RoomScreenViewModelTests: XCTestCase {
|
||||
var userIndicatorControllerMock: UserIndicatorControllerMock!
|
||||
var cancellables = Set<AnyCancellable>()
|
||||
|
||||
override func setUp() async throws {
|
||||
userIndicatorControllerMock = UserIndicatorControllerMock.default
|
||||
@@ -195,15 +198,17 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: userIndicatorControllerMock)
|
||||
viewModel.callback = { action in
|
||||
switch action {
|
||||
case .displayRoomMemberDetails(let member):
|
||||
XCTAssert(member === roomMemberMock)
|
||||
default:
|
||||
XCTFail("Did not received the expected action")
|
||||
viewModel.actions
|
||||
.sink { action in
|
||||
switch action {
|
||||
case .displayRoomMemberDetails(let member):
|
||||
XCTAssert(member === roomMemberMock)
|
||||
default:
|
||||
XCTFail("Did not received the expected action")
|
||||
}
|
||||
expectation.fulfill()
|
||||
}
|
||||
expectation.fulfill()
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
// Test
|
||||
viewModel.context.send(viewAction: .tappedOnUser(userID: "bob"))
|
||||
@@ -232,15 +237,17 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: userIndicatorControllerMock)
|
||||
|
||||
viewModel.callback = { action in
|
||||
switch action {
|
||||
case .displayRoomMemberDetails(let member):
|
||||
XCTAssert(member === roomMemberMock)
|
||||
expectation.fulfill()
|
||||
default:
|
||||
XCTFail("Did not received the expected action")
|
||||
viewModel.actions
|
||||
.sink { action in
|
||||
switch action {
|
||||
case .displayRoomMemberDetails(let member):
|
||||
XCTAssert(member === roomMemberMock)
|
||||
expectation.fulfill()
|
||||
default:
|
||||
XCTFail("Did not received the expected action")
|
||||
}
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
// Test
|
||||
viewModel.context.send(viewAction: .tappedOnUser(userID: "bob"))
|
||||
@@ -268,9 +275,11 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: userIndicatorControllerMock)
|
||||
viewModel.callback = { _ in
|
||||
XCTFail("Should not receive any action")
|
||||
}
|
||||
viewModel.actions
|
||||
.sink { _ in
|
||||
XCTFail("Should not receive any action")
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
// Test
|
||||
let deferred = deferFulfillment(viewModel.context.$viewState.collect(2).first(),
|
||||
|
||||
Reference in New Issue
Block a user