mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-11 13:59:13 +00:00

* Use a Date for the timestamp in all timeline items. * UI test snapshots. * Update snapshots --------- Co-authored-by: Stefan Ceriu <stefanc@matrix.org>
69 lines
3.7 KiB
Swift
69 lines
3.7 KiB
Swift
//
|
|
// Copyright 2023, 2024 New Vector Ltd.
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
// Please see LICENSE in the repository root for full details.
|
|
//
|
|
|
|
@testable import ElementX
|
|
import XCTest
|
|
|
|
final class TextBasedRoomTimelineTests: XCTestCase {
|
|
func testTextRoomTimelineItemWhitespaceEnd() {
|
|
let timestamp = Calendar.current.startOfDay(for: .now).addingTimeInterval(60 * 60) // 1:00 am
|
|
let timelineItem = TextRoomTimelineItem(id: .randomEvent,
|
|
timestamp: timestamp,
|
|
isOutgoing: true,
|
|
isEditable: true,
|
|
canBeRepliedTo: true,
|
|
isThreaded: false,
|
|
sender: .init(id: UUID().uuidString),
|
|
content: .init(body: "Test"))
|
|
XCTAssertEqual(timelineItem.additionalWhitespaces(), timestamp.formattedTime().count + 1)
|
|
}
|
|
|
|
func testTextRoomTimelineItemWhitespaceEndLonger() {
|
|
let timestamp = Calendar.current.startOfDay(for: .now).addingTimeInterval(-60) // 11:59 pm
|
|
let timelineItem = TextRoomTimelineItem(id: .randomEvent,
|
|
timestamp: timestamp,
|
|
isOutgoing: true,
|
|
isEditable: true,
|
|
canBeRepliedTo: true,
|
|
isThreaded: false,
|
|
sender: .init(id: UUID().uuidString),
|
|
content: .init(body: "Test"))
|
|
XCTAssertEqual(timelineItem.additionalWhitespaces(), timestamp.formattedTime().count + 1)
|
|
}
|
|
|
|
func testTextRoomTimelineItemWhitespaceEndWithEdit() {
|
|
let timestamp = Date.mock
|
|
var timelineItem = TextRoomTimelineItem(id: .randomEvent,
|
|
timestamp: timestamp,
|
|
isOutgoing: true,
|
|
isEditable: true,
|
|
canBeRepliedTo: true,
|
|
isThreaded: false,
|
|
sender: .init(id: UUID().uuidString),
|
|
content: .init(body: "Test"))
|
|
timelineItem.properties.isEdited = true
|
|
let editedCount = L10n.commonEditedSuffix.count
|
|
XCTAssertEqual(timelineItem.additionalWhitespaces(), timestamp.formattedTime().count + editedCount + 2)
|
|
}
|
|
|
|
func testTextRoomTimelineItemWhitespaceEndWithEditAndAlert() {
|
|
let timestamp = Date.mock
|
|
var timelineItem = TextRoomTimelineItem(id: .randomEvent,
|
|
timestamp: timestamp,
|
|
isOutgoing: true,
|
|
isEditable: true,
|
|
canBeRepliedTo: true,
|
|
isThreaded: false,
|
|
sender: .init(id: UUID().uuidString),
|
|
content: .init(body: "Test"))
|
|
timelineItem.properties.isEdited = true
|
|
timelineItem.properties.deliveryStatus = .sendingFailed(.unknown)
|
|
let editedCount = L10n.commonEditedSuffix.count
|
|
XCTAssertEqual(timelineItem.additionalWhitespaces(), timestamp.formattedTime().count + editedCount + 5)
|
|
}
|
|
}
|