forked from stripe/stripe-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c0db7df
commit 8ad9814
Showing
9 changed files
with
317 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
link/src/main/java/com/stripe/android/link/ui/inline/SignUpConsentAction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.stripe.android.link.ui.inline | ||
|
||
import androidx.annotation.RestrictTo | ||
|
||
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) | ||
enum class SignUpConsentAction { | ||
Checkbox, | ||
CheckboxWithPrefilledEmail, | ||
CheckboxWithPrefilledEmailAndPhone, | ||
Implied, | ||
ImpliedWithPrefilledEmail | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import com.stripe.android.link.analytics.LinkEventsReporter | |
import com.stripe.android.link.model.AccountStatus | ||
import com.stripe.android.link.repositories.LinkRepository | ||
import com.stripe.android.link.ui.inline.LinkSignupMode | ||
import com.stripe.android.link.ui.inline.SignUpConsentAction | ||
import com.stripe.android.link.ui.inline.UserInput | ||
import com.stripe.android.model.CardParams | ||
import com.stripe.android.model.ConsumerPaymentDetails | ||
|
@@ -138,7 +139,15 @@ class LinkAccountManagerTest { | |
val country = "country" | ||
val name = "name" | ||
|
||
accountManager.signInWithUserInput(UserInput.SignUp(EMAIL, phone, country, name)) | ||
accountManager.signInWithUserInput( | ||
UserInput.SignUp( | ||
email = EMAIL, | ||
phone = phone, | ||
country = country, | ||
name = name, | ||
consentAction = SignUpConsentAction.Checkbox | ||
) | ||
) | ||
|
||
verify(linkRepository).consumerSignUp( | ||
email = eq(EMAIL), | ||
|
@@ -151,6 +160,56 @@ class LinkAccountManagerTest { | |
assertThat(accountManager.linkAccount.value).isNotNull() | ||
} | ||
|
||
@Test | ||
fun `signInWithUserInput sends correct consumer action on 'Checkbox' consent action`() = runSuspendTest { | ||
accountManager().signInWithUserInput(createUserInputWithAction(SignUpConsentAction.Checkbox)) | ||
|
||
verifyConsumerAction(ConsumerSignUpConsentAction.Checkbox) | ||
} | ||
|
||
@Test | ||
fun `signInWithUserInput sends correct consumer action on 'CheckboxWithPrefilledEmail' consent action`() = | ||
runSuspendTest { | ||
accountManager().signInWithUserInput( | ||
createUserInputWithAction( | ||
SignUpConsentAction.CheckboxWithPrefilledEmail | ||
) | ||
) | ||
|
||
verifyConsumerAction(ConsumerSignUpConsentAction.CheckboxWithPrefilledEmail) | ||
} | ||
|
||
@Test | ||
fun `signInWithUserInput sends correct consumer action on 'CheckboxWithPrefilledEmailAndPhone' consent action`() = | ||
runSuspendTest { | ||
accountManager().signInWithUserInput( | ||
createUserInputWithAction( | ||
SignUpConsentAction.CheckboxWithPrefilledEmailAndPhone | ||
) | ||
) | ||
|
||
verifyConsumerAction(ConsumerSignUpConsentAction.CheckboxWithPrefilledEmailAndPhone) | ||
} | ||
|
||
@Test | ||
fun `signInWithUserInput sends correct consumer action on 'Implied' consent action`() = runSuspendTest { | ||
accountManager().signInWithUserInput(createUserInputWithAction(SignUpConsentAction.Implied)) | ||
|
||
verifyConsumerAction(ConsumerSignUpConsentAction.Implied) | ||
} | ||
|
||
@Test | ||
fun `signInWithUserInput sends correct consumer action on 'ImpliedWithPrefilledEmail' consent action`() = | ||
runSuspendTest { | ||
accountManager().signInWithUserInput( | ||
createUserInputWithAction( | ||
SignUpConsentAction.ImpliedWithPrefilledEmail | ||
) | ||
) | ||
|
||
verifyConsumerAction(ConsumerSignUpConsentAction.ImpliedWithPrefilledEmail) | ||
} | ||
|
||
@Test | ||
fun `signInWithUserInput for new user sends analytics event when call succeeds`() = | ||
runSuspendTest { | ||
|
@@ -159,7 +218,8 @@ class LinkAccountManagerTest { | |
email = EMAIL, | ||
phone = "phone", | ||
country = "country", | ||
name = "name" | ||
name = "name", | ||
consentAction = SignUpConsentAction.Checkbox | ||
) | ||
) | ||
|
||
|
@@ -178,7 +238,8 @@ class LinkAccountManagerTest { | |
email = EMAIL, | ||
phone = "phone", | ||
country = "country", | ||
name = "name" | ||
name = "name", | ||
consentAction = SignUpConsentAction.Checkbox | ||
) | ||
) | ||
|
||
|
@@ -202,7 +263,8 @@ class LinkAccountManagerTest { | |
email = EMAIL, | ||
phone = "phone", | ||
country = "country", | ||
name = "name" | ||
name = "name", | ||
consentAction = SignUpConsentAction.Checkbox | ||
) | ||
) | ||
|
||
|
@@ -228,7 +290,8 @@ class LinkAccountManagerTest { | |
email = EMAIL, | ||
phone = "phone", | ||
country = "country", | ||
name = "name" | ||
name = "name", | ||
consentAction = SignUpConsentAction.Checkbox | ||
) | ||
) | ||
|
||
|
@@ -390,6 +453,27 @@ class LinkAccountManagerTest { | |
linkEventsReporter, | ||
) | ||
|
||
private fun createUserInputWithAction(consentAction: SignUpConsentAction): UserInput.SignUp { | ||
return UserInput.SignUp( | ||
email = EMAIL, | ||
phone = "phone", | ||
country = "country", | ||
name = "name", | ||
consentAction = consentAction | ||
) | ||
} | ||
|
||
private suspend fun verifyConsumerAction(consumerAction: ConsumerSignUpConsentAction) { | ||
verify(linkRepository).consumerSignUp( | ||
email = any(), | ||
phone = any(), | ||
country = any(), | ||
name = anyOrNull(), | ||
authSessionCookie = anyOrNull(), | ||
consentAction = eq(consumerAction) | ||
) | ||
} | ||
|
||
private companion object { | ||
const val EMAIL = "[email protected]" | ||
const val CLIENT_SECRET = "client_secret" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.