1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package social.grain
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
import social.grain.feature.profile.ProfileUiState
/**
* Favorites belong to the viewer, so the tab only exists on your own profile.
* The screen keys the whole tab bar off [ProfileUiState.isOwnProfile], so this
* is the flag that decides it.
*/
class ProfileTabVisibilityTest {
private val me = "did:plc:me"
private val someoneElse = "did:plc:other"
@Test
fun `own profile is recognised`() {
val state = ProfileUiState(did = me, viewerDid = me)
assertTrue(state.isOwnProfile)
}
@Test
fun `another account's profile is not`() {
val state = ProfileUiState(did = someoneElse, viewerDid = me)
assertFalse(state.isOwnProfile)
}
@Test
fun `a signed-out viewer owns no profile`() {
// Guards against null == null reading as a match and showing the tab.
assertFalse(ProfileUiState(did = someoneElse, viewerDid = null).isOwnProfile)
assertFalse(ProfileUiState(did = "", viewerDid = null).isOwnProfile)
}
}