BIT-2443: Fix crash caused by extra blank spaces in name (#3395)

This commit is contained in:
David Perez 2024-07-02 16:24:03 -05:00 committed by GitHub
parent bb6a7af423
commit ba95a53ebf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View file

@ -18,7 +18,7 @@ import java.util.Locale
*/
val AccountSummary.initials: String
get() {
val names = this.name.orEmpty().split(" ")
val names = this.name.orEmpty().split(" ").filter { it.isNotBlank() }
return if (names.size >= 2) {
names
.take(2)

View file

@ -12,11 +12,11 @@ class AccountSummaryExtensionsTest {
@Suppress("MaxLineLength")
@Test
fun `initials should return the starting letters of the first two words for a multi-word name`() {
fun `initials should return the starting letters of the first two words for a multi-word name and ignore any extra spaces`() {
assertEquals(
"FS",
mockk<AccountSummary> {
every { name } returns "First Second Third"
every { name } returns "First Second Third"
}
.initials,
)