mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Fix more unit tests. (#1406)
- Randomise test order. - Use deferred fulfilment in more places. - Make sure to change something before awaiting the fulfilment. - Build a fresh AppSettings after reset(). - Retry tests on failure.
This commit is contained in:
@@ -248,7 +248,7 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
XCTAssertEqual(roomProxyMock.getMemberUserIDReceivedUserID, "bob")
|
||||
}
|
||||
|
||||
func testGoToUserDetailsFailure() async {
|
||||
func testGoToUserDetailsFailure() async throws {
|
||||
// Setup
|
||||
let timelineController = MockRoomTimelineController()
|
||||
let roomProxyMock = RoomProxyMock(with: .init(displayName: ""))
|
||||
@@ -269,14 +269,16 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
}
|
||||
|
||||
// Test
|
||||
let deferred = deferFulfillment(viewModel.context.$viewState.collect(2).first(),
|
||||
message: "The existing view state plus one new one should be published.")
|
||||
viewModel.context.send(viewAction: .tappedOnUser(userID: "bob"))
|
||||
await viewModel.context.nextViewState()
|
||||
try await deferred.fulfill()
|
||||
XCTAssertFalse(viewModel.state.bindings.alertInfo.isNil)
|
||||
XCTAssert(roomProxyMock.getMemberUserIDCallsCount == 1)
|
||||
XCTAssertEqual(roomProxyMock.getMemberUserIDReceivedUserID, "bob")
|
||||
}
|
||||
|
||||
func testRetrySend() async {
|
||||
func testRetrySend() async throws {
|
||||
// Setup
|
||||
let timelineController = MockRoomTimelineController()
|
||||
let roomProxyMock = RoomProxyMock(with: .init(displayName: ""))
|
||||
|
||||
Reference in New Issue
Block a user