From 5679cecd8c49ae32439d8fa9aa219c00cf26c0bb Mon Sep 17 00:00:00 2001 From: Mauro Romito Date: Wed, 4 Jun 2025 16:33:27 +0200 Subject: [PATCH] fixed tests --- UnitTests/Sources/HomeScreenRoomTests.swift | 3 ++- UnitTests/Sources/LoggingTests.swift | 3 ++- UnitTests/Sources/RoomSummaryTests.swift | 23 ++++++++++++++++----- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/UnitTests/Sources/HomeScreenRoomTests.swift b/UnitTests/Sources/HomeScreenRoomTests.swift index 389e89ccd..b15bbc1ef 100644 --- a/UnitTests/Sources/HomeScreenRoomTests.swift +++ b/UnitTests/Sources/HomeScreenRoomTests.swift @@ -38,7 +38,8 @@ class HomeScreenRoomTests: XCTestCase { alternativeAliases: [], hasOngoingCall: hasOngoingCall, isMarkedUnread: isMarkedUnread, - isFavourite: false) + isFavourite: false, + isTombstoned: false) } func testNoBadge() { diff --git a/UnitTests/Sources/LoggingTests.swift b/UnitTests/Sources/LoggingTests.swift index 2803e45d0..a4137a5dc 100644 --- a/UnitTests/Sources/LoggingTests.swift +++ b/UnitTests/Sources/LoggingTests.swift @@ -96,7 +96,8 @@ class LoggingTests: XCTestCase { alternativeAliases: [], hasOngoingCall: false, isMarkedUnread: false, - isFavourite: false) + isFavourite: false, + isTombstoned: false) // When logging that value MXLog.info(roomSummary) diff --git a/UnitTests/Sources/RoomSummaryTests.swift b/UnitTests/Sources/RoomSummaryTests.swift index f4bec212d..eb718d0a3 100644 --- a/UnitTests/Sources/RoomSummaryTests.swift +++ b/UnitTests/Sources/RoomSummaryTests.swift @@ -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) } }