mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Replace individual RoomProxy properties with a stored RoomInfo. (#3445)
* Store RoomInfo updates in JoinedRoomProxy and read from them directly. * Remove all RoomProxy properties that were reading from the RoomInfo.
This commit is contained in:
@@ -349,10 +349,11 @@ class TimelineViewModelTests: XCTestCase {
|
||||
// MARK: - Pins
|
||||
|
||||
func testPinnedEvents() async throws {
|
||||
let roomProxyMock = JoinedRoomProxyMock(.init(name: "",
|
||||
pinnedEventIDs: .init(["test1"])))
|
||||
let actionsSubject = PassthroughSubject<JoinedRoomProxyAction, Never>()
|
||||
roomProxyMock.underlyingActionsPublisher = actionsSubject.eraseToAnyPublisher()
|
||||
var configuration = JoinedRoomProxyMockConfiguration(name: "",
|
||||
pinnedEventIDs: .init(["test1"]))
|
||||
let roomProxyMock = JoinedRoomProxyMock(configuration)
|
||||
let infoSubject = CurrentValueSubject<RoomInfoProxy, Never>(.init(roomInfo: RoomInfo(configuration)))
|
||||
roomProxyMock.underlyingInfoPublisher = infoSubject.asCurrentValuePublisher()
|
||||
|
||||
let viewModel = TimelineViewModel(roomProxy: roomProxyMock,
|
||||
timelineController: MockRoomTimelineController(),
|
||||
@@ -364,24 +365,21 @@ class TimelineViewModelTests: XCTestCase {
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings))
|
||||
XCTAssertEqual(configuration.pinnedEventIDs, viewModel.context.viewState.pinnedEventIDs)
|
||||
|
||||
var deferred = deferFulfillment(viewModel.context.$viewState) { value in
|
||||
value.pinnedEventIDs == ["test1"]
|
||||
}
|
||||
try await deferred.fulfill()
|
||||
|
||||
roomProxyMock.underlyingPinnedEventIDs = ["test1", "test2"]
|
||||
deferred = deferFulfillment(viewModel.context.$viewState) { value in
|
||||
configuration.pinnedEventIDs = ["test1", "test2"]
|
||||
let deferred = deferFulfillment(viewModel.context.$viewState) { value in
|
||||
value.pinnedEventIDs == ["test1", "test2"]
|
||||
}
|
||||
actionsSubject.send(.roomInfoUpdate)
|
||||
infoSubject.send(.init(roomInfo: RoomInfo(configuration)))
|
||||
try await deferred.fulfill()
|
||||
}
|
||||
|
||||
func testCanUserPinEvents() async throws {
|
||||
let roomProxyMock = JoinedRoomProxyMock(.init(name: "", canUserPin: true))
|
||||
let actionsSubject = PassthroughSubject<JoinedRoomProxyAction, Never>()
|
||||
roomProxyMock.underlyingActionsPublisher = actionsSubject.eraseToAnyPublisher()
|
||||
let configuration = JoinedRoomProxyMockConfiguration(name: "", canUserPin: true)
|
||||
let roomProxyMock = JoinedRoomProxyMock(configuration)
|
||||
let infoSubject = CurrentValueSubject<RoomInfoProxy, Never>(.init(roomInfo: RoomInfo(configuration)))
|
||||
roomProxyMock.underlyingInfoPublisher = infoSubject.asCurrentValuePublisher()
|
||||
|
||||
let viewModel = TimelineViewModel(roomProxy: roomProxyMock,
|
||||
timelineController: MockRoomTimelineController(),
|
||||
@@ -403,7 +401,7 @@ class TimelineViewModelTests: XCTestCase {
|
||||
deferred = deferFulfillment(viewModel.context.$viewState) { value in
|
||||
!value.canCurrentUserPin
|
||||
}
|
||||
actionsSubject.send(.roomInfoUpdate)
|
||||
infoSubject.send(.init(roomInfo: RoomInfo(configuration)))
|
||||
try await deferred.fulfill()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user