mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
change: decline and block design tweaks
This commit is contained in:
@@ -12,8 +12,61 @@ import XCTest
|
||||
@MainActor
|
||||
class DeclineAndBlockScreenViewModelTests: XCTestCase {
|
||||
var viewModel: DeclineAndBlockScreenViewModelProtocol!
|
||||
var clientProxy: ClientProxyMock!
|
||||
|
||||
var context: DeclineAndBlockScreenViewModelType.Context {
|
||||
viewModel.context
|
||||
}
|
||||
|
||||
override func setUp() {
|
||||
clientProxy = ClientProxyMock(.init())
|
||||
viewModel = DeclineAndBlockScreenViewModel(userID: "@alice:matrix.org",
|
||||
roomID: "!room:matrix.org",
|
||||
clientProxy: clientProxy,
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
}
|
||||
|
||||
func testInitialState() {
|
||||
XCTAssertFalse(context.viewState.isDeclineDisabled)
|
||||
XCTAssertFalse(context.shouldReport)
|
||||
XCTAssertTrue(context.shouldBlockUser)
|
||||
}
|
||||
|
||||
func testDeclineDisabled() {
|
||||
context.shouldBlockUser = false
|
||||
XCTAssertTrue(context.viewState.isDeclineDisabled)
|
||||
XCTAssertFalse(context.shouldReport)
|
||||
XCTAssertFalse(context.shouldBlockUser)
|
||||
}
|
||||
|
||||
func testDeclineBlockAndReport() async throws {
|
||||
let reason = "Test reason"
|
||||
clientProxy.roomForIdentifierClosure = { id in
|
||||
XCTAssertEqual(id, "!room:matrix.org")
|
||||
let roomProxyMock = InvitedRoomProxyMock(.init(id: id))
|
||||
roomProxyMock.rejectInvitationReturnValue = .success(())
|
||||
return .invited(InvitedRoomProxyMock(.init(id: id)))
|
||||
}
|
||||
clientProxy.reportRoomForIdentifierReasonClosure = { id, reasonValue in
|
||||
XCTAssertEqual(id, "!room:matrix.org")
|
||||
XCTAssertEqual(reasonValue, reason)
|
||||
return .success(())
|
||||
}
|
||||
clientProxy.ignoreUserClosure = { userId in
|
||||
XCTAssertEqual(userId, "@alice:matrix.org")
|
||||
return .success(())
|
||||
}
|
||||
|
||||
context.shouldReport = true
|
||||
context.reportReason = reason
|
||||
|
||||
let deferredAction = deferFulfillment(viewModel.actionsPublisher) { action in
|
||||
action == .dismiss(hasDeclined: true)
|
||||
}
|
||||
context.send(viewAction: .decline)
|
||||
try await deferredAction.fulfill()
|
||||
XCTAssertTrue(clientProxy.roomForIdentifierCalled)
|
||||
XCTAssertTrue(clientProxy.reportRoomForIdentifierReasonCalled)
|
||||
XCTAssertTrue(clientProxy.ignoreUserCalled)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user