Skip to content

Commit

Permalink
Add test to cover new cases
Browse files Browse the repository at this point in the history
  • Loading branch information
AnasNaouchi committed Nov 6, 2023
1 parent ea4c48d commit 58d6781
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions sdk/src/test/java/co/omise/android/ui/ExpiryDateEditTextTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ class ExpiryDateEditTextTest {
assertEquals("12/34", editText.text.toString())
}

@Test
fun inputLengthExceedsMaxChars() {
val s = "123456" // 6 characters, assuming MAX_CHARS is 5
s.forEach { editText.append(it.toString()) }
assertEquals("12/34", editText.text.toString()) // assuming that exceeding chars will not be appended
}

@Test
fun inputContainsNonNumericOrSeparator() {
val s = "12ab" // 'ab' are non-numeric characters
s.forEach { editText.append(it.toString()) }
assertEquals("12/", editText.text.toString()) // assuming that non-numeric characters are not appended
}

@Test(expected = InputValidationException.EmptyInputException::class)
fun validate_emptyValue() {
"".forEach { editText.append(it.toString()) }
Expand Down

0 comments on commit 58d6781

Please sign in to comment.