Show a blank topic as removed. (#3706)

This commit is contained in:
Doug
2025-01-27 11:44:21 +00:00
committed by GitHub
parent 13a404560d
commit 62611be006
2 changed files with 27 additions and 5 deletions
@@ -80,4 +80,26 @@ class RoomStateEventStringBuilderTests: XCTestCase {
memberIsYou: sender.id == userID)
XCTAssertEqual(string, expectedString)
}
func testTopicChanges() {
let you = TimelineItemSender(id: userID, displayName: "Alice")
let other = TimelineItemSender(id: "@bob:matrix.org", displayName: "Bob")
let newTopic = "New topic"
var string = stringBuilder.buildString(for: .roomTopic(topic: newTopic), sender: you, isOutgoing: true)
XCTAssertEqual(string, L10n.stateEventRoomTopicChangedByYou(newTopic))
string = stringBuilder.buildString(for: .roomTopic(topic: newTopic), sender: other, isOutgoing: false)
XCTAssertEqual(string, L10n.stateEventRoomTopicChanged(other.displayName ?? "", newTopic))
let emptyTopic = ""
string = stringBuilder.buildString(for: .roomTopic(topic: emptyTopic), sender: you, isOutgoing: true)
XCTAssertEqual(string, L10n.stateEventRoomTopicRemovedByYou)
string = stringBuilder.buildString(for: .roomTopic(topic: emptyTopic), sender: other, isOutgoing: false)
XCTAssertEqual(string, L10n.stateEventRoomTopicRemoved(other.displayName ?? ""))
string = stringBuilder.buildString(for: .roomTopic(topic: nil), sender: you, isOutgoing: true)
XCTAssertEqual(string, L10n.stateEventRoomTopicRemovedByYou)
string = stringBuilder.buildString(for: .roomTopic(topic: nil), sender: other, isOutgoing: false)
XCTAssertEqual(string, L10n.stateEventRoomTopicRemoved(other.displayName ?? ""))
}
}