UI and unit tests

This commit is contained in:
Aleksandrs Proskurins
2022-10-11 17:19:32 +03:00
parent c3b4630e76
commit b7b3e18778
3 changed files with 140 additions and 21 deletions
@@ -27,6 +27,7 @@ enum MockUserOtherSessionsScreenState: MockScreenState, CaseIterable {
case all
case inactiveSessions
case unverifiedSessions
case verifiedSessions
/// The associated screen
var screenType: Any.Type {
@@ -36,7 +37,7 @@ enum MockUserOtherSessionsScreenState: MockScreenState, CaseIterable {
/// A list of screen state definitions
static var allCases: [MockUserOtherSessionsScreenState] {
// Each of the presence statuses
[.all, .inactiveSessions, .unverifiedSessions]
[.all, .inactiveSessions, .unverifiedSessions, .verifiedSessions]
}
/// Generate the view struct for the screen state.
@@ -55,6 +56,10 @@ enum MockUserOtherSessionsScreenState: MockScreenState, CaseIterable {
viewModel = UserOtherSessionsViewModel(sessionInfos: unverifiedSessions(),
filter: .unverified,
title: VectorL10n.userOtherSessionSecurityRecommendationTitle)
case .verifiedSessions:
viewModel = UserOtherSessionsViewModel(sessionInfos: verifiedSessions(),
filter: .verified,
title: VectorL10n.userOtherSessionSecurityRecommendationTitle)
}
// can simulate service and viewModel actions here if needs be.
@@ -167,6 +172,41 @@ enum MockUserOtherSessionsScreenState: MockScreenState, CaseIterable {
isCurrent: false)]
}
private func verifiedSessions() -> [UserSessionInfo] {
[UserSessionInfo(id: "0",
name: "iOS",
deviceType: .mobile,
isVerified: true,
lastSeenIP: "10.0.0.10",
lastSeenTimestamp: nil,
applicationName: nil,
applicationVersion: nil,
applicationURL: nil,
deviceModel: nil,
deviceOS: nil,
lastSeenIPLocation: nil,
clientName: nil,
clientVersion: nil,
isActive: true,
isCurrent: true),
UserSessionInfo(id: "1",
name: "macOS",
deviceType: .desktop,
isVerified: true,
lastSeenIP: "1.0.0.1",
lastSeenTimestamp: Date().timeIntervalSince1970 - 8_000_000,
applicationName: nil,
applicationVersion: nil,
applicationURL: nil,
deviceModel: nil,
deviceOS: nil,
lastSeenIPLocation: nil,
clientName: nil,
clientVersion: nil,
isActive: true,
isCurrent: false)]
}
private func allSessions() -> [UserSessionInfo] {
[UserSessionInfo(id: "0",
name: "iOS",