Skip to content

Commit

Permalink
Fix mandate text disappearing
Browse files Browse the repository at this point in the history
  • Loading branch information
jameswoo-stripe committed Oct 27, 2023
1 parent a5b1121 commit 0c6357d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ internal sealed class PaymentSelection : Parcelable {
override val paymentMethodOptionsParams: PaymentMethodOptionsParams? = null,
) : New() {

override fun mandateText(
context: Context,
merchantName: String,
isSaveForFutureUseSelected: Boolean,
): String? {
return screenState.mandateText
}

@Parcelize
data class Input(
val name: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,24 @@ class PaymentSelectionTest {
)
}

@Test
fun `Displays the correct mandate for US Bank Account`() {
val paymentSelection = PaymentSelection.Saved(
paymentMethod = PaymentMethodFactory.usBankAccount(),
)

val result = paymentSelection.mandateText(
context = context,
merchantName = "Merchant",
isSaveForFutureUseSelected = false,
)

assertThat(result).isEqualTo(
"By continuing, you agree to authorize payments pursuant to " +
"<a href=\"https://stripe.com/ach-payments/authorization\">these terms</a>."
)
}

@Test
fun `Doesn't display a mandate for a saved payment method that isn't US bank account`() =
runAllConfigurations { isSaveForFutureUseSelected ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class USBankAccountFormViewModelTest {
val currentScreenState = viewModel.currentScreenState.stateIn(viewModel.viewModelScope).value
viewModel.handlePrimaryButtonClick(currentScreenState as USBankAccountFormScreenState.VerifyWithMicrodeposits)

assertThat(awaitItem().screenState).isEqualTo(currentScreenState)
assertThat(awaitItem().screenState).isEqualTo(currentScreenState.copy(isProcessing = true))
}
}

Expand All @@ -163,7 +163,7 @@ class USBankAccountFormViewModelTest {
val currentScreenState = viewModel.currentScreenState.stateIn(viewModel.viewModelScope).value
viewModel.handlePrimaryButtonClick(currentScreenState as USBankAccountFormScreenState.MandateCollection)

assertThat(awaitItem().screenState).isEqualTo(currentScreenState)
assertThat(awaitItem().screenState).isEqualTo(currentScreenState.copy(isProcessing = true))
}
}

Expand All @@ -178,7 +178,7 @@ class USBankAccountFormViewModelTest {
val currentScreenState = viewModel.currentScreenState.stateIn(viewModel.viewModelScope).value
viewModel.handlePrimaryButtonClick(currentScreenState as USBankAccountFormScreenState.VerifyWithMicrodeposits)

assertThat(awaitItem().screenState).isEqualTo(currentScreenState)
assertThat(awaitItem().screenState).isEqualTo(currentScreenState.copy(isProcessing = true))
}
}

Expand All @@ -193,7 +193,7 @@ class USBankAccountFormViewModelTest {
val currentScreenState = viewModel.currentScreenState.stateIn(viewModel.viewModelScope).value
viewModel.handlePrimaryButtonClick(currentScreenState as USBankAccountFormScreenState.MandateCollection)

assertThat(awaitItem().screenState).isEqualTo(currentScreenState)
assertThat(awaitItem().screenState).isEqualTo(currentScreenState.copy(isProcessing = true))
}
}

Expand Down

0 comments on commit 0c6357d

Please sign in to comment.