BIT-1215: Improve handling of avatar initials for missing names (#308)

This commit is contained in:
Brian Yencho
2024-06-20 17:08:07 +01:00
committed by Álison Fernandes
parent a4e11af784
commit 79ca73ec00
2 changed files with 27 additions and 9 deletions
@@ -12,7 +12,7 @@ class AccountSummaryExtensionsTest {
@Suppress("MaxLineLength")
@Test
fun `initials should return the starting letters of the first two words in the name if present`() {
fun `initials should return the starting letters of the first two words for a multi-word name`() {
assertEquals(
"FS",
mockk<AccountSummary>() {
@@ -23,11 +23,24 @@ class AccountSummaryExtensionsTest {
}
@Test
fun `initials should return a default value if the name is not present`() {
fun `initials should return the first two letters of the name for a single word name`() {
assertEquals(
"..",
"FI",
mockk<AccountSummary>() {
every { name } returns "First"
}
.initials,
)
}
@Suppress("MaxLineLength")
@Test
fun `initials should return the first two letters of the user's email if the name is not present`() {
assertEquals(
"TE",
mockk<AccountSummary>() {
every { name } returns null
every { email } returns "test@bitwarden.com"
}
.initials,
)