fix unit test

This commit is contained in:
Valere 2023-10-11 17:04:05 +02:00
parent cd101f871c
commit 5f68f98d3a
4 changed files with 11 additions and 4 deletions

View File

@ -35,7 +35,7 @@ class RefreshDevicesUseCaseTest {
fun `given current session when refreshing then devices list and keys are fetched`() {
val session = fakeActiveSessionHolder.fakeSession
coEvery { session.cryptoService().fetchDevicesList() } returns emptyList()
coEvery { session.cryptoService().downloadKeysIfNeeded(any()) } returns MXUsersDevicesMap()
coEvery { session.cryptoService().downloadKeysIfNeeded(any(), any()) } returns MXUsersDevicesMap()
runBlocking {
refreshDevicesUseCase.execute()

View File

@ -46,6 +46,7 @@ import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.matrix.android.sdk.api.session.homeserver.HomeServerCapabilities
import org.matrix.android.sdk.api.session.uia.DefaultBaseAuth
private const val A_DEVICE_ID_1 = "device-id-1"
@ -87,8 +88,10 @@ class OtherSessionsViewModelTest {
// Needed for internal usage of Flow<T>.throttleFirst() inside the ViewModel
mockkStatic(SystemClock::class)
every { SystemClock.elapsedRealtime() } returns 1234
givenVerificationService()
fakeActiveSessionHolder.fakeSession.fakeHomeServerCapabilitiesService.givenCapabilities(
HomeServerCapabilities()
)
givenVerificationService().givenEventFlow()
fakeVectorPreferences.givenSessionManagerShowIpAddress(false)
}

View File

@ -52,6 +52,7 @@ import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.matrix.android.sdk.api.session.crypto.model.RoomEncryptionTrustLevel
import org.matrix.android.sdk.api.session.homeserver.HomeServerCapabilities
import org.matrix.android.sdk.api.session.uia.DefaultBaseAuth
private const val A_SESSION_ID_1 = "session-id-1"
@ -101,6 +102,9 @@ class SessionOverviewViewModelTest {
mockkStatic(SystemClock::class)
every { SystemClock.elapsedRealtime() } returns 1234
fakeActiveSessionHolder.fakeSession.fakeHomeServerCapabilitiesService.givenCapabilities(
HomeServerCapabilities()
)
givenVerificationService()
fakeGetNotificationsStatusUseCase.givenExecuteReturns(
fakeActiveSessionHolder.fakeSession,

View File

@ -43,7 +43,7 @@ class RenameSessionUseCaseTest {
fun `given a device id and a new name when no error during rename then the device is renamed with success`() = runTest {
// Given
fakeActiveSessionHolder.fakeSession.fakeCryptoService.givenSetDeviceNameSucceeds()
coVerify { refreshDevicesUseCase.execute() }
coEvery { refreshDevicesUseCase.execute() } returns Unit
// When
val result = renameSessionUseCase.execute(A_DEVICE_ID, A_DEVICE_NAME)