Introduce Announcement enum.
This commit is contained in:
parent
93c273468e
commit
d7f39c332f
7 changed files with 38 additions and 13 deletions
|
|
@ -18,6 +18,7 @@ import androidx.compose.runtime.rememberCoroutineScope
|
|||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import dev.zacsweers.metro.Inject
|
||||
import io.element.android.features.announcement.api.Announcement
|
||||
import io.element.android.features.announcement.api.AnnouncementService
|
||||
import io.element.android.features.home.impl.roomlist.RoomListState
|
||||
import io.element.android.features.home.impl.spaces.HomeSpacesState
|
||||
|
|
@ -88,7 +89,7 @@ class HomePresenter(
|
|||
when (event) {
|
||||
is HomeEvents.SelectHomeNavigationBarItem -> coroutineState.launch {
|
||||
if (event.item == HomeNavigationBarItem.Spaces) {
|
||||
announcementService.onEnteringSpaceTab()
|
||||
announcementService.showAnnouncement(Announcement.Space)
|
||||
}
|
||||
currentHomeNavigationBarItemOrdinal = event.item.ordinal
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import app.cash.molecule.RecompositionMode
|
|||
import app.cash.molecule.moleculeFlow
|
||||
import app.cash.turbine.test
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import io.element.android.features.announcement.api.Announcement
|
||||
import io.element.android.features.announcement.api.AnnouncementService
|
||||
import io.element.android.features.home.impl.roomlist.aRoomListState
|
||||
import io.element.android.features.home.impl.spaces.HomeSpacesState
|
||||
|
|
@ -40,6 +41,7 @@ import io.element.android.libraries.sessionstorage.test.aSessionData
|
|||
import io.element.android.tests.testutils.MutablePresenter
|
||||
import io.element.android.tests.testutils.WarmUpRule
|
||||
import io.element.android.tests.testutils.lambda.lambdaRecorder
|
||||
import io.element.android.tests.testutils.lambda.value
|
||||
import io.element.android.tests.testutils.test
|
||||
import kotlinx.coroutines.flow.flowOf
|
||||
import kotlinx.coroutines.test.runTest
|
||||
|
|
@ -168,13 +170,13 @@ class HomePresenterTest {
|
|||
|
||||
@Test
|
||||
fun `present - NavigationBar change`() = runTest {
|
||||
val onEnteringSpaceTabResult = lambdaRecorder<Unit> { }
|
||||
val showAnnouncementResult = lambdaRecorder<Announcement, Unit> { }
|
||||
val presenter = createHomePresenter(
|
||||
sessionStore = InMemorySessionStore(
|
||||
updateUserProfileResult = { _, _, _ -> },
|
||||
),
|
||||
announcementService = FakeAnnouncementService(
|
||||
onEnteringSpaceTabResult = onEnteringSpaceTabResult,
|
||||
showAnnouncementResult = showAnnouncementResult,
|
||||
)
|
||||
)
|
||||
moleculeFlow(RecompositionMode.Immediate) {
|
||||
|
|
@ -185,7 +187,8 @@ class HomePresenterTest {
|
|||
initialState.eventSink(HomeEvents.SelectHomeNavigationBarItem(HomeNavigationBarItem.Spaces))
|
||||
val finalState = awaitItem()
|
||||
assertThat(finalState.currentHomeNavigationBarItem).isEqualTo(HomeNavigationBarItem.Spaces)
|
||||
onEnteringSpaceTabResult.assertions().isCalledOnce()
|
||||
showAnnouncementResult.assertions().isCalledOnce()
|
||||
.with(value(Announcement.Space))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -201,7 +204,7 @@ class HomePresenterTest {
|
|||
),
|
||||
homeSpacesPresenter = homeSpacesPresenter,
|
||||
announcementService = FakeAnnouncementService(
|
||||
onEnteringSpaceTabResult = {},
|
||||
showAnnouncementResult = {},
|
||||
)
|
||||
)
|
||||
presenter.test {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue