For #23813 - Clear error message for nameOnCardLayout when valid name is submitted
This commit is contained in:
parent
6df5bd7d74
commit
f1070e05c2
|
@ -132,7 +132,7 @@ class CreditCardEditorView(
|
|||
}
|
||||
|
||||
if (binding.nameOnCardInput.text.toString().isNotBlank()) {
|
||||
binding.nameOnCardInput.error = null
|
||||
binding.nameOnCardLayout.error = null
|
||||
binding.nameOnCardTitle.setTextColor(binding.root.context.getColorFromAttr(R.attr.textPrimary))
|
||||
} else {
|
||||
isValid = false
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.junit.Assert.assertEquals
|
|||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
@ -209,6 +210,40 @@ class CreditCardEditorViewTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN invalid credit card values WHEN valid values are entered and the save button is clicked THEN error messages are cleared`() {
|
||||
creditCardEditorView.bind(getInitialCreditCardEditorState())
|
||||
|
||||
var billingName = ""
|
||||
var cardNumber = "1234567891234567"
|
||||
val expiryMonth = 5
|
||||
|
||||
fragmentCreditCardEditorBinding.cardNumberInput.text = cardNumber.toEditable()
|
||||
fragmentCreditCardEditorBinding.nameOnCardInput.text = billingName.toEditable()
|
||||
fragmentCreditCardEditorBinding.expiryMonthDropDown.setSelection(expiryMonth - 1)
|
||||
|
||||
fragmentCreditCardEditorBinding.saveButton.performClick()
|
||||
|
||||
verify {
|
||||
creditCardEditorView.validateForm()
|
||||
}
|
||||
|
||||
billingName = "Banana Apple"
|
||||
cardNumber = "2720994326581252"
|
||||
fragmentCreditCardEditorBinding.nameOnCardInput.text = billingName.toEditable()
|
||||
fragmentCreditCardEditorBinding.cardNumberInput.text = cardNumber.toEditable()
|
||||
|
||||
fragmentCreditCardEditorBinding.saveButton.performClick()
|
||||
|
||||
verify {
|
||||
creditCardEditorView.validateForm()
|
||||
}
|
||||
|
||||
assertTrue(creditCardEditorView.validateForm())
|
||||
assertNull(fragmentCreditCardEditorBinding.cardNumberLayout.error)
|
||||
assertNull(fragmentCreditCardEditorBinding.nameOnCardLayout.error)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN invalid name on card WHEN the save button is clicked THEN interactor is not called`() {
|
||||
creditCardEditorView.bind(getInitialCreditCardEditorState())
|
||||
|
|
Loading…
Reference in New Issue