Skip to content

Commit

Permalink
Fix UTs
Browse files Browse the repository at this point in the history
  • Loading branch information
alfogrillo committed Nov 2, 2022
1 parent 956cd6d commit 668fdac
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class UserOtherSessionsViewModelTests: XCTestCase {
header: inactiveSectionHeader,
emptyItemsTitle: VectorL10n.userOtherSessionNoInactiveSessions,
allItemsSelected: false,
enableSignOutButton: false)
enableSignOutButton: false,
showLocationInfo: false)
XCTAssertEqual(sut.state, expectedState)
}

Expand All @@ -79,7 +80,8 @@ class UserOtherSessionsViewModelTests: XCTestCase {
header: allSectionHeader,
emptyItemsTitle: "",
allItemsSelected: false,
enableSignOutButton: false)
enableSignOutButton: false,
showLocationInfo: false)
XCTAssertEqual(sut.state, expectedState)
}

Expand All @@ -96,7 +98,8 @@ class UserOtherSessionsViewModelTests: XCTestCase {
header: unverifiedSectionHeader,
emptyItemsTitle: VectorL10n.userOtherSessionNoUnverifiedSessions,
allItemsSelected: false,
enableSignOutButton: false)
enableSignOutButton: false,
showLocationInfo: false)
XCTAssertEqual(sut.state, expectedState)
}

Expand All @@ -113,7 +116,8 @@ class UserOtherSessionsViewModelTests: XCTestCase {
header: verifiedSectionHeader,
emptyItemsTitle: VectorL10n.userOtherSessionNoVerifiedSessions,
allItemsSelected: false,
enableSignOutButton: false)
enableSignOutButton: false,
showLocationInfo: false)
XCTAssertEqual(sut.state, expectedState)
}

Expand All @@ -128,7 +132,8 @@ class UserOtherSessionsViewModelTests: XCTestCase {
header: verifiedSectionHeader,
emptyItemsTitle: VectorL10n.userOtherSessionNoVerifiedSessions,
allItemsSelected: false,
enableSignOutButton: false)
enableSignOutButton: false,
showLocationInfo: false)
XCTAssertEqual(sut.state, expectedState)
}

Expand All @@ -143,7 +148,8 @@ class UserOtherSessionsViewModelTests: XCTestCase {
header: unverifiedSectionHeader,
emptyItemsTitle: VectorL10n.userOtherSessionNoUnverifiedSessions,
allItemsSelected: false,
enableSignOutButton: false)
enableSignOutButton: false,
showLocationInfo: false)
XCTAssertEqual(sut.state, expectedState)
}

Expand All @@ -158,7 +164,8 @@ class UserOtherSessionsViewModelTests: XCTestCase {
header: inactiveSectionHeader,
emptyItemsTitle: VectorL10n.userOtherSessionNoInactiveSessions,
allItemsSelected: false,
enableSignOutButton: false)
enableSignOutButton: false,
showLocationInfo: false)
XCTAssertEqual(sut.state, expectedState)
}

Expand All @@ -178,7 +185,8 @@ class UserOtherSessionsViewModelTests: XCTestCase {
header: allSectionHeader,
emptyItemsTitle: "",
allItemsSelected: true,
enableSignOutButton: true)
enableSignOutButton: true,
showLocationInfo: false)
XCTAssertEqual(sut.state, expectedState)
}

Expand All @@ -198,7 +206,8 @@ class UserOtherSessionsViewModelTests: XCTestCase {
header: allSectionHeader,
emptyItemsTitle: "",
allItemsSelected: false,
enableSignOutButton: false)
enableSignOutButton: false,
showLocationInfo: false)
XCTAssertEqual(sut.state, expectedState)
}

Expand All @@ -217,7 +226,8 @@ class UserOtherSessionsViewModelTests: XCTestCase {
header: allSectionHeader,
emptyItemsTitle: "",
allItemsSelected: false,
enableSignOutButton: true)
enableSignOutButton: true,
showLocationInfo: false)
XCTAssertEqual(sut.state, expectedState)
}

Expand All @@ -236,7 +246,8 @@ class UserOtherSessionsViewModelTests: XCTestCase {
header: allSectionHeader,
emptyItemsTitle: "",
allItemsSelected: true,
enableSignOutButton: true)
enableSignOutButton: true,
showLocationInfo: false)
XCTAssertEqual(sut.state, expectedState)
}

Expand All @@ -255,7 +266,8 @@ class UserOtherSessionsViewModelTests: XCTestCase {
header: allSectionHeader,
emptyItemsTitle: "",
allItemsSelected: false,
enableSignOutButton: false)
enableSignOutButton: false,
showLocationInfo: false)
XCTAssertEqual(sut.state, expectedState)
}

Expand All @@ -277,7 +289,8 @@ class UserOtherSessionsViewModelTests: XCTestCase {
header: allSectionHeader,
emptyItemsTitle: "",
allItemsSelected: false,
enableSignOutButton: false)
enableSignOutButton: false,
showLocationInfo: false)
XCTAssertEqual(sut.state, expectedState)
}

Expand Down Expand Up @@ -332,7 +345,8 @@ class UserOtherSessionsViewModelTests: XCTestCase {
title: String = "Title") -> UserOtherSessionsViewModel {
UserOtherSessionsViewModel(sessionInfos: sessionInfos,
filter: filter,
title: title)
title: title,
settingService: MockUserSessionSettings())
}

private func createUserSessionInfo(sessionId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import XCTest
class UserSessionOverviewViewModelTests: XCTestCase {
func test_whenVerifyCurrentSessionProcessed_completionWithVerifyCurrentSessionCalled() {
let sessionInfo = createUserSessionInfo()
let sut = UserSessionOverviewViewModel(sessionInfo: sessionInfo, service: MockUserSessionOverviewService())
let sut = UserSessionOverviewViewModel(sessionInfo: sessionInfo, service: MockUserSessionOverviewService(), settingsService: MockUserSessionSettings())

XCTAssertEqual(sut.state.isPusherEnabled, nil)
var modelResult: UserSessionOverviewViewModelResult?
Expand All @@ -35,7 +35,7 @@ class UserSessionOverviewViewModelTests: XCTestCase {

func test_whenViewSessionDetailsProcessed_completionWithShowSessionDetailsCalled() {
let sessionInfo = createUserSessionInfo()
let sut = UserSessionOverviewViewModel(sessionInfo: sessionInfo, service: MockUserSessionOverviewService())
let sut = UserSessionOverviewViewModel(sessionInfo: sessionInfo, service: MockUserSessionOverviewService(), settingsService: MockUserSessionSettings())

XCTAssertEqual(sut.state.isPusherEnabled, nil)
var modelResult: UserSessionOverviewViewModelResult?
Expand All @@ -49,7 +49,7 @@ class UserSessionOverviewViewModelTests: XCTestCase {
func test_whenViewSessionDetailsProcessed_toggleAvailablePusher() {
let sessionInfo = createUserSessionInfo()
let service = MockUserSessionOverviewService(pusherEnabled: true)
let sut = UserSessionOverviewViewModel(sessionInfo: sessionInfo, service: service)
let sut = UserSessionOverviewViewModel(sessionInfo: sessionInfo, service: service, settingsService: MockUserSessionSettings())

XCTAssertTrue(sut.state.remotelyTogglingPushersAvailable)
XCTAssertEqual(sut.state.isPusherEnabled, true)
Expand All @@ -62,7 +62,7 @@ class UserSessionOverviewViewModelTests: XCTestCase {
func test_whenViewSessionDetailsProcessed_toggleNoPusher() {
let sessionInfo = createUserSessionInfo()
let service = MockUserSessionOverviewService(pusherEnabled: nil)
let sut = UserSessionOverviewViewModel(sessionInfo: sessionInfo, service: service)
let sut = UserSessionOverviewViewModel(sessionInfo: sessionInfo, service: service, settingsService: MockUserSessionSettings())

XCTAssertTrue(sut.state.remotelyTogglingPushersAvailable)
XCTAssertEqual(sut.state.isPusherEnabled, nil)
Expand All @@ -75,7 +75,7 @@ class UserSessionOverviewViewModelTests: XCTestCase {
func test_whenViewSessionDetailsProcessed_remotelyTogglingPushersNotAvailable() {
let sessionInfo = createUserSessionInfo()
let service = MockUserSessionOverviewService(pusherEnabled: true, remotelyTogglingPushersAvailable: false)
let sut = UserSessionOverviewViewModel(sessionInfo: sessionInfo, service: service)
let sut = UserSessionOverviewViewModel(sessionInfo: sessionInfo, service: service, settingsService: MockUserSessionSettings())

XCTAssertFalse(sut.state.remotelyTogglingPushersAvailable)
XCTAssertEqual(sut.state.isPusherEnabled, true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import XCTest

class UserSessionsOverviewViewModelTests: XCTestCase {
func testInitialStateEmpty() {
let viewModel = UserSessionsOverviewViewModel(userSessionsOverviewService: MockUserSessionsOverviewService())
let viewModel = UserSessionsOverviewViewModel(userSessionsOverviewService: MockUserSessionsOverviewService(), settingsService: MockUserSessionSettings())

XCTAssertNil(viewModel.state.currentSessionViewData)
XCTAssertTrue(viewModel.state.unverifiedSessionsViewData.isEmpty)
Expand All @@ -31,7 +31,7 @@ class UserSessionsOverviewViewModelTests: XCTestCase {
}

func testLoadOnDidAppear() {
let viewModel = UserSessionsOverviewViewModel(userSessionsOverviewService: MockUserSessionsOverviewService())
let viewModel = UserSessionsOverviewViewModel(userSessionsOverviewService: MockUserSessionsOverviewService(), settingsService: MockUserSessionSettings())
viewModel.process(viewAction: .viewAppeared)

XCTAssertNotNil(viewModel.state.currentSessionViewData)
Expand All @@ -42,7 +42,7 @@ class UserSessionsOverviewViewModelTests: XCTestCase {
}

func testSimpleActionProcessing() {
let viewModel = UserSessionsOverviewViewModel(userSessionsOverviewService: MockUserSessionsOverviewService())
let viewModel = UserSessionsOverviewViewModel(userSessionsOverviewService: MockUserSessionsOverviewService(), settingsService: MockUserSessionSettings())

var result: UserSessionsOverviewViewModelResult?
viewModel.completion = { action in
Expand All @@ -69,7 +69,7 @@ class UserSessionsOverviewViewModelTests: XCTestCase {
let service = MockUserSessionsOverviewService()
service.updateOverviewData { _ in }

let viewModel = UserSessionsOverviewViewModel(userSessionsOverviewService: service)
let viewModel = UserSessionsOverviewViewModel(userSessionsOverviewService: service, settingsService: MockUserSessionSettings())

var result: UserSessionsOverviewViewModelResult?
viewModel.completion = { action in
Expand Down

0 comments on commit 668fdac

Please sign in to comment.