fixed tests

This commit is contained in:
Mauro Romito
2025-06-04 16:33:27 +02:00
committed by Mauro
parent d05108796f
commit 5679cecd8c
3 changed files with 22 additions and 7 deletions

View File

@@ -15,7 +15,7 @@ class RoomSummaryTests: XCTestCase {
let heroes = [UserProfileProxy(userID: "hero_1", displayName: "Hero 1", avatarURL: "mxc://hs.tld/user/avatar")]
func testRoomAvatar() {
let details = makeSummary(isDirect: false, hasRoomAvatar: true)
let details = makeSummary(isDirect: false, hasRoomAvatar: true, isTombstoned: false)
switch details.avatar {
case .room(let id, let name, let avatarURL):
@@ -24,11 +24,13 @@ class RoomSummaryTests: XCTestCase {
XCTAssertEqual(avatarURL, roomDetails.avatarURL)
case .heroes:
XCTFail("A room shouldn't use the heroes for its avatar.")
case .tombstoned:
XCTFail("A room shouldn't use the tombstone for its avatar.")
}
}
func testDMAvatarSet() {
let details = makeSummary(isDirect: true, hasRoomAvatar: true)
let details = makeSummary(isDirect: true, hasRoomAvatar: true, isTombstoned: false)
switch details.avatar {
case .room(let id, let name, let avatarURL):
@@ -37,23 +39,33 @@ class RoomSummaryTests: XCTestCase {
XCTAssertEqual(avatarURL, roomDetails.avatarURL)
case .heroes:
XCTFail("A DM with an avatar set shouldn't use the heroes instead.")
case .tombstoned:
XCTFail("A room shouldn't use the tombstone for its avatar.")
}
}
func testDMAvatarNotSet() {
let details = makeSummary(isDirect: true, hasRoomAvatar: false)
let details = makeSummary(isDirect: true, hasRoomAvatar: false, isTombstoned: false)
switch details.avatar {
case .room:
XCTFail("A DM without an avatar should defer to the hero for the correct placeholder tint colour.")
case .heroes(let heroes):
XCTAssertEqual(heroes, self.heroes)
case .tombstoned:
XCTFail("A room shouldn't use the tombstone for its avatar.")
}
}
func testTombstonedAvatar() {
let details = makeSummary(isDirect: false, hasRoomAvatar: true, isTombstoned: true)
XCTAssertEqual(details.avatar, .tombstoned)
}
// MARK: - Helpers
func makeSummary(isDirect: Bool, hasRoomAvatar: Bool) -> RoomSummary {
func makeSummary(isDirect: Bool, hasRoomAvatar: Bool, isTombstoned: Bool) -> RoomSummary {
RoomSummary(room: .init(noPointer: .init()),
id: roomDetails.id,
joinRequestType: nil,
@@ -72,6 +84,7 @@ class RoomSummaryTests: XCTestCase {
alternativeAliases: [],
hasOngoingCall: false,
isMarkedUnread: false,
isFavourite: false)
isFavourite: false,
isTombstoned: isTombstoned)
}
}