Skip to content

Commit

Permalink
update LoginToutViewModel Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
scottkicks committed Apr 8, 2024
1 parent ab6898e commit f770e59
Showing 1 changed file with 26 additions and 31 deletions.
57 changes: 26 additions & 31 deletions Library/ViewModels/LoginToutViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,7 @@ final class LoginToutViewModelTests: TestCase {
}

func testLoginIntent_Pledge() {
let reward = Reward.template
|> Reward.lens.id .~ 10
let project = Project.template
|> Project.lens.id .~ 2

self.vm.inputs.configureWith(.backProject, project: project, reward: reward)
self.vm.inputs.configureWith(.backProject)
self.vm.inputs.viewWillAppear()

self.logInContextText.assertValues(
Expand All @@ -70,7 +65,7 @@ final class LoginToutViewModelTests: TestCase {
}

func testStartLogin() {
self.vm.inputs.configureWith(.activity, project: nil, reward: nil)
self.vm.inputs.configureWith(.activity)
self.vm.inputs.viewWillAppear()
self.vm.inputs.loginButtonPressed()

Expand All @@ -83,7 +78,7 @@ final class LoginToutViewModelTests: TestCase {
}

func testStartLogin_PledgeIntent() {
self.vm.inputs.configureWith(.backProject, project: .template, reward: .template)
self.vm.inputs.configureWith(.backProject)
self.vm.inputs.viewWillAppear()
self.vm.inputs.loginButtonPressed()

Expand All @@ -96,7 +91,7 @@ final class LoginToutViewModelTests: TestCase {
}

func testStartSignup() {
self.vm.inputs.configureWith(.activity, project: nil, reward: nil)
self.vm.inputs.configureWith(.activity)
self.vm.inputs.viewWillAppear()
self.vm.inputs.signupButtonPressed()

Expand All @@ -109,7 +104,7 @@ final class LoginToutViewModelTests: TestCase {
}

func testStartSignup_PledgeIntent() {
self.vm.inputs.configureWith(.backProject, project: .template, reward: .template)
self.vm.inputs.configureWith(.backProject)
self.vm.inputs.viewWillAppear()
self.vm.inputs.signupButtonPressed()

Expand Down Expand Up @@ -159,21 +154,21 @@ final class LoginToutViewModelTests: TestCase {
}

func testHeadlineLabelHidden() {
self.vm.inputs.configureWith(.starProject, project: nil, reward: nil)
self.vm.inputs.configureWith(.starProject)
self.vm.inputs.viewWillAppear()

self.headlineLabelHidden.assertValues([true])
}

func testHeadlineLabelShown() {
self.vm.inputs.configureWith(.generic, project: nil, reward: nil)
self.vm.inputs.configureWith(.generic)
self.vm.inputs.viewWillAppear()

self.headlineLabelHidden.assertValues([false])
}

func testLoginContextText() {
self.vm.inputs.configureWith(.starProject, project: nil, reward: nil)
self.vm.inputs.configureWith(.starProject)
self.vm.inputs.viewWillAppear()

self.logInContextText.assertValues(
Expand Down Expand Up @@ -207,7 +202,7 @@ final class LoginToutViewModelTests: TestCase {
)

withEnvironment(remoteConfigClient: mockRemoteConfigClient) {
self.vm.inputs.configureWith(.generic, project: nil, reward: nil)
self.vm.inputs.configureWith(.generic)
self.vm.inputs.viewWillAppear()

self.attemptFacebookLogin.assertValueCount(0, "Attempt Facebook login did not emit")
Expand Down Expand Up @@ -263,7 +258,7 @@ final class LoginToutViewModelTests: TestCase {
)

withEnvironment(remoteConfigClient: mockRemoteConfigClient) {
self.vm.inputs.configureWith(.generic, project: nil, reward: nil)
self.vm.inputs.configureWith(.generic)
self.vm.inputs.viewWillAppear()

self.attemptFacebookLogin.assertValueCount(0, "Attempt Facebook login did not emit")
Expand Down Expand Up @@ -310,7 +305,7 @@ final class LoginToutViewModelTests: TestCase {
]
)

self.vm.inputs.configureWith(.generic, project: nil, reward: nil)
self.vm.inputs.configureWith(.generic)
self.vm.inputs.viewWillAppear()

self.attemptFacebookLogin.assertValueCount(0, "Attempt Facebook login did not emit")
Expand Down Expand Up @@ -338,7 +333,7 @@ final class LoginToutViewModelTests: TestCase {
userInfo: [:]
)

self.vm.inputs.configureWith(.generic, project: nil, reward: nil)
self.vm.inputs.configureWith(.generic)
self.vm.inputs.viewWillAppear()

self.attemptFacebookLogin.assertValueCount(0, "Attempt Facebook login did not emit")
Expand Down Expand Up @@ -388,7 +383,7 @@ final class LoginToutViewModelTests: TestCase {
)

withEnvironment(apiService: MockService(loginError: error)) {
self.vm.inputs.configureWith(.generic, project: nil, reward: nil)
self.vm.inputs.configureWith(.generic)
self.vm.inputs.viewWillAppear()

self.showFacebookErrorAlert.assertValueCount(0, "Facebook login fail does not emit")
Expand Down Expand Up @@ -437,7 +432,7 @@ final class LoginToutViewModelTests: TestCase {
)

withEnvironment(apiService: MockService(loginError: error)) {
self.vm.inputs.configureWith(.generic, project: nil, reward: nil)
self.vm.inputs.configureWith(.generic)
self.vm.inputs.viewWillAppear()

self.vm.inputs.facebookLoginButtonPressed()
Expand Down Expand Up @@ -484,7 +479,7 @@ final class LoginToutViewModelTests: TestCase {
)

withEnvironment(apiService: MockService(loginError: error)) {
self.vm.inputs.configureWith(.generic, project: nil, reward: nil)
self.vm.inputs.configureWith(.generic)
self.vm.inputs.viewWillAppear()

self.vm.inputs.facebookLoginButtonPressed()
Expand Down Expand Up @@ -531,7 +526,7 @@ final class LoginToutViewModelTests: TestCase {
)

withEnvironment(apiService: MockService(loginError: error)) {
self.vm.inputs.configureWith(.generic, project: nil, reward: nil)
self.vm.inputs.configureWith(.generic)
self.vm.inputs.viewWillAppear()

self.vm.inputs.facebookLoginButtonPressed()
Expand Down Expand Up @@ -581,7 +576,7 @@ final class LoginToutViewModelTests: TestCase {
)

withEnvironment(apiService: MockService(loginError: error)) {
self.vm.inputs.configureWith(.generic, project: nil, reward: nil)
self.vm.inputs.configureWith(.generic)
self.vm.inputs.viewWillAppear()

self.vm.inputs.facebookLoginButtonPressed()
Expand Down Expand Up @@ -618,7 +613,7 @@ final class LoginToutViewModelTests: TestCase {
}

func testDismissalWhenNotPresented() {
self.vm.inputs.configureWith(.generic, project: nil, reward: nil)
self.vm.inputs.configureWith(.generic)
self.vm.inputs.viewWillAppear()
self.vm.inputs.view(isPresented: false)
self.vm.inputs.userSessionStarted()
Expand All @@ -627,7 +622,7 @@ final class LoginToutViewModelTests: TestCase {
}

func testDismissalWhenPresented() {
self.vm.inputs.configureWith(.generic, project: nil, reward: nil)
self.vm.inputs.configureWith(.generic)
self.vm.inputs.viewWillAppear()
self.vm.inputs.view(isPresented: true)
self.vm.inputs.userSessionStarted()
Expand All @@ -636,7 +631,7 @@ final class LoginToutViewModelTests: TestCase {
}

func testShowAppleErrorAlert_DoesNotEmitWhen_CancellingSignInWithAppleModal() {
self.vm.inputs.configureWith(.generic, project: nil, reward: nil)
self.vm.inputs.configureWith(.generic)
self.vm.inputs.viewWillAppear()

self.vm.inputs.appleAuthorizationDidFail(with: .canceled)
Expand All @@ -649,7 +644,7 @@ final class LoginToutViewModelTests: TestCase {
domain: "notonlinesorry", code: -1_234, userInfo: [NSLocalizedDescriptionKey: "Not online sorry"]
)

self.vm.inputs.configureWith(.generic, project: nil, reward: nil)
self.vm.inputs.configureWith(.generic)
self.vm.inputs.viewWillAppear()

self.vm.inputs.appleAuthorizationDidFail(with: .other(error))
Expand All @@ -659,7 +654,7 @@ final class LoginToutViewModelTests: TestCase {

func testShowAppleErrorAlert_SignInWithAppleMutationError() {
withEnvironment(apiService: MockService(signInWithAppleResult: .failure(.couldNotParseJSON))) {
self.vm.inputs.configureWith(.generic, project: nil, reward: nil)
self.vm.inputs.configureWith(.generic)
self.vm.inputs.viewWillAppear()

let data = SignInWithAppleData(
Expand Down Expand Up @@ -690,7 +685,7 @@ final class LoginToutViewModelTests: TestCase {
fetchUserResult: .failure(.couldNotParseJSON),
signInWithAppleResult: .success(envelope)
)) {
self.vm.inputs.configureWith(.generic, project: nil, reward: nil)
self.vm.inputs.configureWith(.generic)
self.vm.inputs.viewWillAppear()

let data = SignInWithAppleData(
Expand Down Expand Up @@ -727,7 +722,7 @@ final class LoginToutViewModelTests: TestCase {
|> \.features .~ [RemoteConfigFeature.facebookLoginInterstitialEnabled.rawValue: false]

withEnvironment(apiService: service, remoteConfigClient: mockRemoteConfigClient) {
self.vm.inputs.configureWith(.generic, project: nil, reward: nil)
self.vm.inputs.configureWith(.generic)
self.vm.inputs.viewWillAppear()

let data = SignInWithAppleData(
Expand Down Expand Up @@ -767,7 +762,7 @@ final class LoginToutViewModelTests: TestCase {
|> \.features .~ [RemoteConfigFeature.facebookLoginInterstitialEnabled.rawValue: true]

withEnvironment(apiService: service, remoteConfigClient: mockRemoteConfigClient) {
self.vm.inputs.configureWith(.generic, project: nil, reward: nil)
self.vm.inputs.configureWith(.generic)
self.vm.inputs.viewWillAppear()

let data = SignInWithAppleData(
Expand Down Expand Up @@ -796,7 +791,7 @@ final class LoginToutViewModelTests: TestCase {
}

func testAttemptAppleLogin_Tracking() {
self.vm.inputs.configureWith(.generic, project: nil, reward: nil)
self.vm.inputs.configureWith(.generic)
self.vm.inputs.viewWillAppear()

self.attemptAppleLogin.assertDidNotEmitValue()
Expand Down

0 comments on commit f770e59

Please sign in to comment.