~ knotless Search/
↑↓ move↵ open⇧↵ all results

grain.social/grain-android

1 collaborator
0
1
main
36 lines · 1.1 KB Raw History
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)
    }
}