mirror of
https://github.com/bitwarden/android.git
synced 2026-06-01 10:16:47 -05:00
BIT-1191: Calculate avatar color when absent (#280)
This commit is contained in:
@@ -135,7 +135,8 @@ class UserStateJsonExtensionsTest {
|
||||
userId = "activeUserId",
|
||||
name = "activeName",
|
||||
email = "activeEmail",
|
||||
avatarColorHex = "activeAvatarColorHex",
|
||||
// This value is calculated from the userId
|
||||
avatarColorHex = "#ffecbc49",
|
||||
isPremium = true,
|
||||
isVaultUnlocked = false,
|
||||
),
|
||||
@@ -149,7 +150,7 @@ class UserStateJsonExtensionsTest {
|
||||
every { userId } returns "activeUserId"
|
||||
every { name } returns "activeName"
|
||||
every { email } returns "activeEmail"
|
||||
every { avatarColorHex } returns "activeAvatarColorHex"
|
||||
every { avatarColorHex } returns null
|
||||
every { hasPremium } returns true
|
||||
},
|
||||
tokens = mockk(),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.x8bit.bitwarden.ui.platform.base.util
|
||||
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertFalse
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.Test
|
||||
@@ -67,4 +68,22 @@ class StringExtensionsTest {
|
||||
assertFalse(badUri.isValidUri())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `toHexColorRepresentation should return valid hex color values`() {
|
||||
mapOf(
|
||||
"First" to "#ff90e20b",
|
||||
"Second" to "#ff943060",
|
||||
"Multiple words" to "#ffb9d46a",
|
||||
"1234567890-=!@#$%^&*()_+[]\\;',./{}|:\"<>?" to "#ff171178",
|
||||
"" to "#ff000000",
|
||||
" " to "#ff200000",
|
||||
)
|
||||
.forEach { (input, colorHexOutput) ->
|
||||
assertEquals(
|
||||
colorHexOutput,
|
||||
input.toHexColorRepresentation(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user