-
Notifications
You must be signed in to change notification settings - Fork 662
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add min length validation to BECS account number (#2293)
- Add validation for BECS account number min length - Update account number min length based on BSB prefix
- Loading branch information
1 parent
1955cc3
commit c6512a9
Showing
5 changed files
with
111 additions
and
8 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
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
43 changes: 43 additions & 0 deletions
43
stripe/src/test/java/com/stripe/android/view/BecsDebitAccountNumberEditTextTest.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,43 @@ | ||
package com.stripe.android.view | ||
|
||
import androidx.test.core.app.ApplicationProvider | ||
import com.google.common.truth.Truth.assertThat | ||
import kotlin.test.Test | ||
import org.junit.runner.RunWith | ||
import org.robolectric.RobolectricTestRunner | ||
|
||
@RunWith(RobolectricTestRunner::class) | ||
class BecsDebitAccountNumberEditTextTest { | ||
private val accountNumberEditText = BecsDebitAccountNumberEditText( | ||
ApplicationProvider.getApplicationContext() | ||
) | ||
|
||
@Test | ||
fun accountNumber_whenEmpty_shouldReturnCorrectErrorMessage() { | ||
accountNumberEditText.setText("") | ||
assertThat(accountNumberEditText.accountNumber) | ||
.isNull() | ||
assertThat(accountNumberEditText.errorMessage) | ||
.isEqualTo("Your account number is required.") | ||
} | ||
|
||
@Test | ||
fun accountNumber_whenIncomplete_shouldReturnCorrectErrorMessage() { | ||
accountNumberEditText.minLength = 9 | ||
accountNumberEditText.setText("1234") | ||
assertThat(accountNumberEditText.accountNumber) | ||
.isNull() | ||
assertThat(accountNumberEditText.errorMessage) | ||
.isEqualTo("Your account number is incomplete.") | ||
} | ||
|
||
@Test | ||
fun accountNumber_whenComplete_shouldNotHaveErrorMessage() { | ||
accountNumberEditText.minLength = 5 | ||
accountNumberEditText.setText("123456") | ||
assertThat(accountNumberEditText.accountNumber) | ||
.isEqualTo("123456") | ||
assertThat(accountNumberEditText.errorMessage) | ||
.isNull() | ||
} | ||
} |
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