mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
fixed tests
This commit is contained in:
@@ -38,7 +38,8 @@ class HomeScreenRoomTests: XCTestCase {
|
|||||||
alternativeAliases: [],
|
alternativeAliases: [],
|
||||||
hasOngoingCall: hasOngoingCall,
|
hasOngoingCall: hasOngoingCall,
|
||||||
isMarkedUnread: isMarkedUnread,
|
isMarkedUnread: isMarkedUnread,
|
||||||
isFavourite: false)
|
isFavourite: false,
|
||||||
|
isTombstoned: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testNoBadge() {
|
func testNoBadge() {
|
||||||
|
|||||||
@@ -96,7 +96,8 @@ class LoggingTests: XCTestCase {
|
|||||||
alternativeAliases: [],
|
alternativeAliases: [],
|
||||||
hasOngoingCall: false,
|
hasOngoingCall: false,
|
||||||
isMarkedUnread: false,
|
isMarkedUnread: false,
|
||||||
isFavourite: false)
|
isFavourite: false,
|
||||||
|
isTombstoned: false)
|
||||||
|
|
||||||
// When logging that value
|
// When logging that value
|
||||||
MXLog.info(roomSummary)
|
MXLog.info(roomSummary)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class RoomSummaryTests: XCTestCase {
|
|||||||
let heroes = [UserProfileProxy(userID: "hero_1", displayName: "Hero 1", avatarURL: "mxc://hs.tld/user/avatar")]
|
let heroes = [UserProfileProxy(userID: "hero_1", displayName: "Hero 1", avatarURL: "mxc://hs.tld/user/avatar")]
|
||||||
|
|
||||||
func testRoomAvatar() {
|
func testRoomAvatar() {
|
||||||
let details = makeSummary(isDirect: false, hasRoomAvatar: true)
|
let details = makeSummary(isDirect: false, hasRoomAvatar: true, isTombstoned: false)
|
||||||
|
|
||||||
switch details.avatar {
|
switch details.avatar {
|
||||||
case .room(let id, let name, let avatarURL):
|
case .room(let id, let name, let avatarURL):
|
||||||
@@ -24,11 +24,13 @@ class RoomSummaryTests: XCTestCase {
|
|||||||
XCTAssertEqual(avatarURL, roomDetails.avatarURL)
|
XCTAssertEqual(avatarURL, roomDetails.avatarURL)
|
||||||
case .heroes:
|
case .heroes:
|
||||||
XCTFail("A room shouldn't use the heroes for its avatar.")
|
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() {
|
func testDMAvatarSet() {
|
||||||
let details = makeSummary(isDirect: true, hasRoomAvatar: true)
|
let details = makeSummary(isDirect: true, hasRoomAvatar: true, isTombstoned: false)
|
||||||
|
|
||||||
switch details.avatar {
|
switch details.avatar {
|
||||||
case .room(let id, let name, let avatarURL):
|
case .room(let id, let name, let avatarURL):
|
||||||
@@ -37,23 +39,33 @@ class RoomSummaryTests: XCTestCase {
|
|||||||
XCTAssertEqual(avatarURL, roomDetails.avatarURL)
|
XCTAssertEqual(avatarURL, roomDetails.avatarURL)
|
||||||
case .heroes:
|
case .heroes:
|
||||||
XCTFail("A DM with an avatar set shouldn't use the heroes instead.")
|
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() {
|
func testDMAvatarNotSet() {
|
||||||
let details = makeSummary(isDirect: true, hasRoomAvatar: false)
|
let details = makeSummary(isDirect: true, hasRoomAvatar: false, isTombstoned: false)
|
||||||
|
|
||||||
switch details.avatar {
|
switch details.avatar {
|
||||||
case .room:
|
case .room:
|
||||||
XCTFail("A DM without an avatar should defer to the hero for the correct placeholder tint colour.")
|
XCTFail("A DM without an avatar should defer to the hero for the correct placeholder tint colour.")
|
||||||
case .heroes(let heroes):
|
case .heroes(let heroes):
|
||||||
XCTAssertEqual(heroes, self.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
|
// MARK: - Helpers
|
||||||
|
|
||||||
func makeSummary(isDirect: Bool, hasRoomAvatar: Bool) -> RoomSummary {
|
func makeSummary(isDirect: Bool, hasRoomAvatar: Bool, isTombstoned: Bool) -> RoomSummary {
|
||||||
RoomSummary(room: .init(noPointer: .init()),
|
RoomSummary(room: .init(noPointer: .init()),
|
||||||
id: roomDetails.id,
|
id: roomDetails.id,
|
||||||
joinRequestType: nil,
|
joinRequestType: nil,
|
||||||
@@ -72,6 +84,7 @@ class RoomSummaryTests: XCTestCase {
|
|||||||
alternativeAliases: [],
|
alternativeAliases: [],
|
||||||
hasOngoingCall: false,
|
hasOngoingCall: false,
|
||||||
isMarkedUnread: false,
|
isMarkedUnread: false,
|
||||||
isFavourite: false)
|
isFavourite: false,
|
||||||
|
isTombstoned: isTombstoned)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user