Add missing test on RustNotificationService
This commit is contained in:
committed by
Benoit Marty
parent
fde4fe871f
commit
0a50c9f9cf
@@ -14,8 +14,11 @@ import org.matrix.rustcomponents.sdk.NotificationItemsRequest
|
||||
|
||||
class FakeFfiNotificationClient(
|
||||
var notificationItemResult: Map<String, NotificationItem> = emptyMap(),
|
||||
val closeResult: () -> Unit = { }
|
||||
) : NotificationClient(NoPointer) {
|
||||
override suspend fun getNotifications(requests: List<NotificationItemsRequest>): Map<String, NotificationItem> {
|
||||
return notificationItemResult
|
||||
}
|
||||
|
||||
override fun close() = closeResult()
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import io.element.android.libraries.matrix.test.A_SESSION_ID
|
||||
import io.element.android.libraries.matrix.test.A_USER_ID_2
|
||||
import io.element.android.services.toolbox.api.systemclock.SystemClock
|
||||
import io.element.android.services.toolbox.test.systemclock.FakeSystemClock
|
||||
import io.element.android.tests.testutils.lambda.lambdaRecorder
|
||||
import io.element.android.tests.testutils.testCoroutineDispatchers
|
||||
import kotlinx.coroutines.test.TestScope
|
||||
import kotlinx.coroutines.test.runTest
|
||||
@@ -61,6 +62,19 @@ class RustNotificationServiceTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `close should invoke the close method of the service`() = runTest {
|
||||
val closeResult = lambdaRecorder<Unit> { }
|
||||
val notificationClient = FakeFfiNotificationClient(
|
||||
closeResult = closeResult,
|
||||
)
|
||||
val sut = createRustNotificationService(
|
||||
notificationClient = notificationClient,
|
||||
)
|
||||
sut.close()
|
||||
closeResult.assertions().isCalledOnce()
|
||||
}
|
||||
|
||||
private fun TestScope.createRustNotificationService(
|
||||
notificationClient: NotificationClient = FakeFfiNotificationClient(),
|
||||
clock: SystemClock = FakeSystemClock(),
|
||||
|
||||
Reference in New Issue
Block a user