Move more MockTimelineController configuration to the constructor

This commit is contained in:
Stefan Ceriu
2026-05-29 12:35:50 +03:00
parent 4830424427
commit 423bd8073f
11 changed files with 73 additions and 105 deletions
@@ -115,8 +115,7 @@ private extension DateFormatter {
struct RoomPollsHistoryScreen_Previews: PreviewProvider, TestablePreview {
static let viewModelEmpty: RoomPollsHistoryScreenViewModel = {
let timelineController = MockTimelineController()
timelineController.timelineItems = []
let timelineController = MockTimelineController(timelineItems: [])
let roomProxyMockConfiguration = JoinedRoomProxyMockConfiguration(name: "Polls")
return RoomPollsHistoryScreenViewModel(pollInteractionHandler: PollInteractionHandlerMock(),
timelineController: timelineController,
@@ -124,20 +123,20 @@ struct RoomPollsHistoryScreen_Previews: PreviewProvider, TestablePreview {
}()
static let viewModel: RoomPollsHistoryScreenViewModel = {
let timelineController = MockTimelineController()
let polls = [PollRoomTimelineItem.mock(poll: .disclosed(createdByAccountOwner: false)),
PollRoomTimelineItem.mock(poll: .disclosed(createdByAccountOwner: true)),
PollRoomTimelineItem.mock(poll: .emptyDisclosed, isEditable: true)]
timelineController.timelineItems = polls
var timelineItemsTimestamps = [TimelineItemIdentifier: Date]()
for i in 0..<polls.count {
let item = polls[i]
let date: Date! = DateComponents(calendar: .current, timeZone: .gmt, year: 2023, month: 12, day: 1 + i, hour: 12).date
timelineController.timelineItemsTimestamp[item.id] = date
timelineItemsTimestamps[item.id] = date
}
let timelineController = MockTimelineController(timelineItems: polls,
timelineItemsTimestamps: timelineItemsTimestamps)
let roomProxyMockConfiguration = JoinedRoomProxyMockConfiguration(name: "Polls", timelineStartReached: true)
return RoomPollsHistoryScreenViewModel(pollInteractionHandler: PollInteractionHandlerMock(),
timelineController: timelineController,