Skip to content

Commit

Permalink
Merge pull request #91 from afterpay/update-configuration-tests
Browse files Browse the repository at this point in the history
Update set configuration tests with locale cases
  • Loading branch information
adamjcampbell authored Oct 22, 2020
2 parents 6e18e8a + 1d38845 commit 8c53720
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 2 additions & 4 deletions afterpay/src/main/kotlin/com/afterpay/android/Afterpay.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,8 @@ object Afterpay {
throw IllegalArgumentException("Minimum order amount is invalid")
}
}

val validCountries = Locales.validSet.map { it.country }

if (!validCountries.contains(configuration.locale.country)) {
if (!Locales.validSet.contains(configuration.locale)) {
val validCountries = Locales.validSet.map { it.country }
throw IllegalArgumentException(
"Locale contains an unsupported country: ${configuration.locale.country}. " +
"Supported countries include: ${validCountries.joinToString(",")}"
Expand Down
12 changes: 12 additions & 0 deletions afterpay/src/test/kotlin/com/afterpay/android/AfterpayTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,16 @@ class AfterpayTest {
)
}
}

@Test
fun `setConfiguration throws for a locale not in the valid set`() {
assertThrows(IllegalArgumentException::class.java) {
Afterpay.setConfiguration(
minimumAmount = "10.00",
maximumAmount = "100.00",
currencyCode = "AUD",
locale = Locale.JAPAN
)
}
}
}

0 comments on commit 8c53720

Please sign in to comment.