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

This commit is contained in:
Brian Yencho
2023-12-02 13:03:33 -06:00
committed by GitHub
parent 1df7726acc
commit fef9d1fa5f
2 changed files with 27 additions and 9 deletions

View File

@@ -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,
)