mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Switch callbacks to combine (#1710)
* #750 - Convert the SoftLogoutScreen to combine * #750 - Convert the UserSessionFlowCoordinator to Combine * #750 - Convert the AnalyticsPromptScreen to Combine * #750 - Convert the LoginScreen to Combine * #750 - Convert the ServerSelectionScreen to Combine * #750 - Convert the EmojiPickerScreen to Combine * #750 - Convert the HomeScreen to Combine * #750 - Convert the MediaUploadPreviewScreen to Combine * #750 - Convert the OnboardingScreen to Combine * Rename `Onboarding` to `OnboardingScreen` * #750 - Convert the ReportContentScreen to Combine * #750 - Convert the RoomDetailsSscreen to Combine * #750 - Convert the RoomMemberDetailsScreen to Combine * #750 - Convert the RoomMembersListScreen to Combine * #750 - Convert the SessionVerificationScreen to Combine * #750 - Convert the SettingsScreen to Combine * #750 - Convert the AdvancedSettingsScreen to Combine * #750 - Convert the DeveloperOptionsScreen to Combine * Fix the unit tests * Use .sink action and the same cancellables constructor everywhere * Cleanup cancellables when setting up tests
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Combine
|
||||
import MatrixRustSDK
|
||||
import SwiftUI
|
||||
import XCTest
|
||||
@@ -26,8 +27,10 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
|
||||
var roomProxyMock: RoomProxyMock!
|
||||
var notificationSettingsProxyMock: NotificationSettingsProxyMock!
|
||||
var context: RoomDetailsScreenViewModelType.Context { viewModel.context }
|
||||
var cancellables = Set<AnyCancellable>()
|
||||
|
||||
override func setUp() {
|
||||
cancellables.removeAll()
|
||||
roomProxyMock = RoomProxyMock(with: .init(displayName: "Test", joinedMembersCount: 0))
|
||||
notificationSettingsProxyMock = NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration())
|
||||
viewModel = RoomDetailsScreenViewModel(accountUserID: "@owner:somewhere.com",
|
||||
@@ -84,15 +87,17 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
|
||||
roomProxyMock.leaveRoomClosure = {
|
||||
.success(())
|
||||
}
|
||||
viewModel.callback = { action in
|
||||
switch action {
|
||||
case .leftRoom:
|
||||
break
|
||||
default:
|
||||
XCTFail("leftRoom expected")
|
||||
viewModel.actions
|
||||
.sink { action in
|
||||
switch action {
|
||||
case .leftRoom:
|
||||
break
|
||||
default:
|
||||
XCTFail("leftRoom expected")
|
||||
}
|
||||
expectation.fulfill()
|
||||
}
|
||||
expectation.fulfill()
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
context.send(viewAction: .confirmLeave)
|
||||
await fulfillment(of: [expectation])
|
||||
XCTAssertEqual(roomProxyMock.leaveRoomCallsCount, 1)
|
||||
@@ -263,14 +268,16 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
|
||||
XCTAssertTrue(context.viewState.canInviteUsers)
|
||||
|
||||
var callbackCorrectlyCalled = false
|
||||
viewModel.callback = { action in
|
||||
switch action {
|
||||
case .requestInvitePeoplePresentation:
|
||||
callbackCorrectlyCalled = true
|
||||
default:
|
||||
callbackCorrectlyCalled = false
|
||||
viewModel.actions
|
||||
.sink { action in
|
||||
switch action {
|
||||
case .requestInvitePeoplePresentation:
|
||||
callbackCorrectlyCalled = true
|
||||
default:
|
||||
callbackCorrectlyCalled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
context.send(viewAction: .processTapInvite)
|
||||
await Task.yield()
|
||||
|
||||
Reference in New Issue
Block a user