mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-10-31 16:22:49 +00:00
RoomDirectoryEvents -> RoomDirectoryEvent
This commit is contained in:
+3
-3
@@ -8,7 +8,7 @@
|
||||
|
||||
package io.element.android.features.roomdirectory.impl.root
|
||||
|
||||
sealed interface RoomDirectoryEvents {
|
||||
data class Search(val query: String) : RoomDirectoryEvents
|
||||
data object LoadMore : RoomDirectoryEvents
|
||||
sealed interface RoomDirectoryEvent {
|
||||
data class Search(val query: String) : RoomDirectoryEvent
|
||||
data object LoadMore : RoomDirectoryEvent
|
||||
}
|
||||
+3
-3
@@ -63,12 +63,12 @@ class RoomDirectoryPresenter(
|
||||
loadingMore = false
|
||||
}
|
||||
}
|
||||
fun handleEvent(event: RoomDirectoryEvents) {
|
||||
fun handleEvent(event: RoomDirectoryEvent) {
|
||||
when (event) {
|
||||
RoomDirectoryEvents.LoadMore -> {
|
||||
RoomDirectoryEvent.LoadMore -> {
|
||||
loadingMore = true
|
||||
}
|
||||
is RoomDirectoryEvents.Search -> {
|
||||
is RoomDirectoryEvent.Search -> {
|
||||
searchQuery = event.query
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ data class RoomDirectoryState(
|
||||
val query: String,
|
||||
val roomDescriptions: ImmutableList<RoomDescription>,
|
||||
val displayLoadMoreIndicator: Boolean,
|
||||
val eventSink: (RoomDirectoryEvents) -> Unit
|
||||
val eventSink: (RoomDirectoryEvent) -> Unit
|
||||
) {
|
||||
val displayEmptyState = roomDescriptions.isEmpty() && !displayLoadMoreIndicator
|
||||
}
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ fun aRoomDirectoryState(
|
||||
query: String = "",
|
||||
displayLoadMoreIndicator: Boolean = false,
|
||||
roomDescriptions: ImmutableList<RoomDescription> = persistentListOf(),
|
||||
eventSink: (RoomDirectoryEvents) -> Unit = {},
|
||||
eventSink: (RoomDirectoryEvent) -> Unit = {},
|
||||
) = RoomDirectoryState(
|
||||
query = query,
|
||||
roomDescriptions = roomDescriptions,
|
||||
|
||||
+2
-2
@@ -107,7 +107,7 @@ private fun RoomDirectoryContent(
|
||||
Column(modifier = modifier) {
|
||||
SearchTextField(
|
||||
query = state.query,
|
||||
onQueryChange = { state.eventSink(RoomDirectoryEvents.Search(it)) },
|
||||
onQueryChange = { state.eventSink(RoomDirectoryEvent.Search(it)) },
|
||||
placeholder = stringResource(id = CommonStrings.action_search),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
@@ -116,7 +116,7 @@ private fun RoomDirectoryContent(
|
||||
displayLoadMoreIndicator = state.displayLoadMoreIndicator,
|
||||
displayEmptyState = state.displayEmptyState,
|
||||
onResultClick = onResultClick,
|
||||
onReachedLoadMore = { state.eventSink(RoomDirectoryEvents.LoadMore) },
|
||||
onReachedLoadMore = { state.eventSink(RoomDirectoryEvent.LoadMore) },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -91,7 +91,7 @@ class RoomDirectoryPresenterTest {
|
||||
val presenter = createRoomDirectoryPresenter(roomDirectoryService = roomDirectoryService)
|
||||
presenter.test {
|
||||
awaitItem().also { state ->
|
||||
state.eventSink(RoomDirectoryEvents.Search("test"))
|
||||
state.eventSink(RoomDirectoryEvent.Search("test"))
|
||||
}
|
||||
awaitItem().also { state ->
|
||||
assertThat(state.query).isEqualTo("test")
|
||||
@@ -112,7 +112,7 @@ class RoomDirectoryPresenterTest {
|
||||
val presenter = createRoomDirectoryPresenter(roomDirectoryService = roomDirectoryService)
|
||||
presenter.test {
|
||||
awaitItem().also { state ->
|
||||
state.eventSink(RoomDirectoryEvents.LoadMore)
|
||||
state.eventSink(RoomDirectoryEvent.LoadMore)
|
||||
}
|
||||
advanceUntilIdle()
|
||||
cancelAndIgnoreRemainingEvents()
|
||||
|
||||
+5
-5
@@ -30,7 +30,7 @@ import org.junit.Test
|
||||
class RoomDirectoryViewTest : RobolectricTest() {
|
||||
@Test
|
||||
fun `typing text in search field emits the expected Event`() = runAndroidComposeUiTest {
|
||||
val eventsRecorder = EventsRecorder<RoomDirectoryEvents>()
|
||||
val eventsRecorder = EventsRecorder<RoomDirectoryEvent>()
|
||||
setRoomDirectoryView(
|
||||
state = aRoomDirectoryState(
|
||||
eventSink = eventsRecorder,
|
||||
@@ -39,12 +39,12 @@ class RoomDirectoryViewTest : RobolectricTest() {
|
||||
onNodeWithTag(TestTags.searchTextField.value).performTextInput(
|
||||
text = "Test"
|
||||
)
|
||||
eventsRecorder.assertSingle(RoomDirectoryEvents.Search("Test"))
|
||||
eventsRecorder.assertSingle(RoomDirectoryEvent.Search("Test"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `clicking on room item then onResultClick lambda is called once`() = runAndroidComposeUiTest {
|
||||
val eventsRecorder = EventsRecorder<RoomDirectoryEvents>()
|
||||
val eventsRecorder = EventsRecorder<RoomDirectoryEvent>()
|
||||
val state = aRoomDirectoryState(
|
||||
roomDescriptions = aRoomDescriptionList(),
|
||||
eventSink = eventsRecorder,
|
||||
@@ -61,13 +61,13 @@ class RoomDirectoryViewTest : RobolectricTest() {
|
||||
|
||||
@Test
|
||||
fun `composing load more indicator emits expected Event`() = runAndroidComposeUiTest {
|
||||
val eventsRecorder = EventsRecorder<RoomDirectoryEvents>()
|
||||
val eventsRecorder = EventsRecorder<RoomDirectoryEvent>()
|
||||
val state = aRoomDirectoryState(
|
||||
displayLoadMoreIndicator = true,
|
||||
eventSink = eventsRecorder,
|
||||
)
|
||||
setRoomDirectoryView(state = state)
|
||||
eventsRecorder.assertSingle(RoomDirectoryEvents.LoadMore)
|
||||
eventsRecorder.assertSingle(RoomDirectoryEvent.LoadMore)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user