Add unit test on elementHeroes()
This commit is contained in:
parent
0c37938f44
commit
9e59aac6c7
1 changed files with 76 additions and 0 deletions
|
|
@ -0,0 +1,76 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2024 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
* Please see LICENSE in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.libraries.matrix.impl.room
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.libraries.matrix.api.core.UserId
|
||||||
|
import io.element.android.libraries.matrix.api.user.MatrixUser
|
||||||
|
import io.element.android.libraries.matrix.impl.fixtures.aRustRoomInfo
|
||||||
|
import io.element.android.libraries.matrix.test.A_USER_ID
|
||||||
|
import org.junit.Test
|
||||||
|
import org.matrix.rustcomponents.sdk.RoomHero
|
||||||
|
|
||||||
|
class RoomInfoExtTest {
|
||||||
|
@Test
|
||||||
|
fun `get non empty element Heroes`() {
|
||||||
|
val result = aRustRoomInfo(
|
||||||
|
isDirect = true,
|
||||||
|
activeMembersCount = 2uL,
|
||||||
|
heroes = listOf(aRoomHero())
|
||||||
|
).elementHeroes()
|
||||||
|
assertThat(result).isEqualTo(
|
||||||
|
listOf(
|
||||||
|
MatrixUser(
|
||||||
|
userId = UserId(A_USER_ID.value),
|
||||||
|
displayName = "displayName",
|
||||||
|
avatarUrl = "avatarUrl",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `too many heroes and element Heroes is empty`() {
|
||||||
|
val result = aRustRoomInfo(
|
||||||
|
isDirect = true,
|
||||||
|
activeMembersCount = 2uL,
|
||||||
|
heroes = listOf(aRoomHero(), aRoomHero())
|
||||||
|
).elementHeroes()
|
||||||
|
assertThat(result).isEmpty()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `not direct and element Heroes is empty`() {
|
||||||
|
val result = aRustRoomInfo(
|
||||||
|
isDirect = false,
|
||||||
|
activeMembersCount = 2uL,
|
||||||
|
heroes = listOf(aRoomHero())
|
||||||
|
).elementHeroes()
|
||||||
|
assertThat(result).isEmpty()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `too many members and element Heroes is empty`() {
|
||||||
|
val result = aRustRoomInfo(
|
||||||
|
isDirect = true,
|
||||||
|
activeMembersCount = 3uL,
|
||||||
|
heroes = listOf(aRoomHero())
|
||||||
|
).elementHeroes()
|
||||||
|
assertThat(result).isEmpty()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun aRoomHero(
|
||||||
|
userId: UserId = A_USER_ID,
|
||||||
|
): RoomHero {
|
||||||
|
return RoomHero(
|
||||||
|
userId = userId.value,
|
||||||
|
displayName = "displayName",
|
||||||
|
avatarUrl = "avatarUrl",
|
||||||
|
)
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue