diff --git a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/ApiAccessMethodDetailsViewModelTest.kt b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/ApiAccessMethodDetailsViewModelTest.kt index 631deb12e46e..63ce73c1a3ae 100644 --- a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/ApiAccessMethodDetailsViewModelTest.kt +++ b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/ApiAccessMethodDetailsViewModelTest.kt @@ -1,12 +1,14 @@ package net.mullvad.mullvadvpn.viewmodel import app.cash.turbine.test +import arrow.core.Either import arrow.core.left import arrow.core.right import io.mockk.coEvery import io.mockk.coVerify import io.mockk.every import io.mockk.mockk +import io.mockk.mockkStatic import java.time.Duration import kotlin.test.assertIs import kotlinx.coroutines.flow.MutableStateFlow @@ -20,6 +22,7 @@ import net.mullvad.mullvadvpn.lib.model.ApiAccessMethodSetting import net.mullvad.mullvadvpn.lib.model.TestApiAccessMethodError import net.mullvad.mullvadvpn.lib.model.UnknownApiAccessMethodError import net.mullvad.mullvadvpn.repository.ApiAccessRepository +import net.mullvad.mullvadvpn.util.delayAtLeast import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -38,6 +41,7 @@ class ApiAccessMethodDetailsViewModelTest { @BeforeEach fun setUp() { + mockkStatic(DELAY_UTIL) every { mockApiAccessRepository.apiAccessMethodSettingById(apiAccessMethodId) } returns accessMethodFlow every { mockApiAccessRepository.enabledApiAccessMethods() } returns enabledMethodsFlow @@ -58,6 +62,8 @@ class ApiAccessMethodDetailsViewModelTest { Unit.right() coEvery { mockApiAccessRepository.setCurrentApiAccessMethod(any()) } returns Unit.right() + coEvery { delayAtLeast>(any(), any()) } returns + Unit.right() // Act apiAccessMethodDetailsViewModel.setCurrentMethod() @@ -177,4 +183,8 @@ class ApiAccessMethodDetailsViewModelTest { ) } } + + companion object { + private const val DELAY_UTIL = "net.mullvad.mullvadvpn.util.DelayKt" + } }