Add test on DefaultEntryPoints
This commit is contained in:
@@ -12,6 +12,6 @@ import com.bumble.appyx.core.node.Node
|
||||
import io.element.android.libraries.architecture.FeatureEntryPoint
|
||||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
|
||||
interface ReportRoomEntryPoint : FeatureEntryPoint {
|
||||
fun interface ReportRoomEntryPoint : FeatureEntryPoint {
|
||||
fun createNode(parentNode: Node, buildContext: BuildContext, roomId: RoomId): Node
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class ReportRoomPresenter(
|
||||
private val reportRoom: ReportRoom,
|
||||
) : Presenter<ReportRoomState> {
|
||||
@AssistedFactory
|
||||
interface Factory {
|
||||
fun interface Factory {
|
||||
fun create(roomId: RoomId): ReportRoomPresenter
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.features.reportroom.impl
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.bumble.appyx.core.modality.BuildContext
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import io.element.android.libraries.matrix.test.A_ROOM_ID
|
||||
import io.element.android.tests.testutils.node.TestParentNode
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class DefaultReportRoomEntryPointTest {
|
||||
@Test
|
||||
fun `test node builder`() {
|
||||
val entryPoint = DefaultReportRoomEntryPoint()
|
||||
val parentNode = TestParentNode.create { buildContext, plugins ->
|
||||
ReportRoomNode(
|
||||
buildContext = buildContext,
|
||||
plugins = plugins,
|
||||
presenterFactory = { roomId ->
|
||||
assertThat(roomId).isEqualTo(A_ROOM_ID)
|
||||
createReportRoomPresenter()
|
||||
}
|
||||
)
|
||||
}
|
||||
val result = entryPoint.createNode(parentNode, BuildContext.root(null), A_ROOM_ID)
|
||||
assertThat(result).isInstanceOf(ReportRoomNode::class.java)
|
||||
assertThat(result.plugins).contains(ReportRoomNode.Inputs(A_ROOM_ID))
|
||||
}
|
||||
}
|
||||
@@ -141,11 +141,11 @@ class ReportRoomPresenterTest {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun createReportRoomPresenter(
|
||||
roomId: RoomId = A_ROOM_ID,
|
||||
reportRoom: ReportRoom = FakeReportRoom()
|
||||
): ReportRoomPresenter {
|
||||
return ReportRoomPresenter(roomId, reportRoom)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun createReportRoomPresenter(
|
||||
roomId: RoomId = A_ROOM_ID,
|
||||
reportRoom: ReportRoom = FakeReportRoom()
|
||||
): ReportRoomPresenter {
|
||||
return ReportRoomPresenter(roomId, reportRoom)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user