Commit 280f7d61 authored by Rafael Kellermann Streit's avatar Rafael Kellermann Streit Committed by GitHub

Merge branch 'develop' into iss321

parents 2d6ffe90 d9e84511
...@@ -70,9 +70,9 @@ object UserAvatarHelper { ...@@ -70,9 +70,9 @@ object UserAvatarHelper {
val splitUsername = username.split(".") val splitUsername = username.split(".")
val splitCount = splitUsername.size val splitCount = splitUsername.size
if (splitCount > 1 && splitUsername[0].isNotEmpty() && splitUsername[1].isNotEmpty()) { if (splitCount > 1 && splitUsername[0].isNotEmpty() && splitUsername[splitCount-1].isNotEmpty()) {
val firstInitial = splitUsername[0].substring(0, 1) val firstInitial = splitUsername[0].substring(0, 1)
val secondInitial = splitUsername[1].substring(0, 1) val secondInitial = splitUsername[splitCount-1].substring(0, 1)
return (firstInitial + secondInitial).toUpperCase() return (firstInitial + secondInitial).toUpperCase()
} else { } else {
if (username.length > 1) { if (username.length > 1) {
......
import chat.rocket.android.widget.helper.UserAvatarHelper import chat.rocket.android.widget.helper.UserAvatarHelper
import org.junit.Test import org.junit.Test
import kotlin.test.assertEquals
class UserAvatarHelperTest { class UserAvatarHelperTest {
@Test @Test
fun getUsernameInitialsTest() { fun getUsernameInitialsTest() {
assert(UserAvatarHelper.getUsernameInitials("") == "?") assertEquals("?", UserAvatarHelper.getUsernameInitials(""))
assert(UserAvatarHelper.getUsernameInitials("?") == "?") assertEquals("?", UserAvatarHelper.getUsernameInitials("?"))
assert(UserAvatarHelper.getUsernameInitials("f") == "F") assertEquals("F", UserAvatarHelper.getUsernameInitials("f"))
assert(UserAvatarHelper.getUsernameInitials("B") == "B") assertEquals("B", UserAvatarHelper.getUsernameInitials("B"))
assert(UserAvatarHelper.getUsernameInitials("fo") == "FO") assertEquals("FO", UserAvatarHelper.getUsernameInitials("Fo"))
assert(UserAvatarHelper.getUsernameInitials("FO") == "FO") assertEquals("FO", UserAvatarHelper.getUsernameInitials("FO"))
assert(UserAvatarHelper.getUsernameInitials("fOo") == "FO") assertEquals("FO", UserAvatarHelper.getUsernameInitials("fOo"))
assert(UserAvatarHelper.getUsernameInitials("FOO") == "FO") assertEquals("FO", UserAvatarHelper.getUsernameInitials("FOO"))
assert(UserAvatarHelper.getUsernameInitials("F.O") == "FO") assertEquals("FO", UserAvatarHelper.getUsernameInitials("F.O"))
assert(UserAvatarHelper.getUsernameInitials("F.o") == "FO") assertEquals("FO", UserAvatarHelper.getUsernameInitials("F.o"))
assert(UserAvatarHelper.getUsernameInitials("Foo.bar") == "FB") assertEquals("FB", UserAvatarHelper.getUsernameInitials("Foo.bar"))
assert(UserAvatarHelper.getUsernameInitials("Foobar.bar") == "FB") assertEquals("FB", UserAvatarHelper.getUsernameInitials("Foobar.bar"))
assert(UserAvatarHelper.getUsernameInitials("Foobar.bar.zab") == "FZ") assertEquals("FZ", UserAvatarHelper.getUsernameInitials("Foobar.bar.zab"))
assert(UserAvatarHelper.getUsernameInitials("..") == "..") assertEquals("..", UserAvatarHelper.getUsernameInitials(".."))
assert(UserAvatarHelper.getUsernameInitials("...") == "..") assertEquals("..", UserAvatarHelper.getUsernameInitials("..."))
assert(UserAvatarHelper.getUsernameInitials(".Foo.") == ".F") assertEquals(".F", UserAvatarHelper.getUsernameInitials(".Foo."))
assert(UserAvatarHelper.getUsernameInitials("Foo..") == "FO") assertEquals("FO", UserAvatarHelper.getUsernameInitials("Foo.."))
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment