From eb093c16e96b832c380d29f29df53382d8447a3f Mon Sep 17 00:00:00 2001 From: Jonatan Rhodin Date: Wed, 22 Nov 2023 15:42:32 +0100 Subject: [PATCH] Fix connect view model tests --- .../mullvadvpn/viewmodel/ConnectViewModelTest.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModelTest.kt b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModelTest.kt index 345a57df8097..0910c5594977 100644 --- a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModelTest.kt +++ b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModelTest.kt @@ -40,6 +40,7 @@ import net.mullvad.mullvadvpn.ui.serviceconnection.ServiceConnectionState import net.mullvad.mullvadvpn.ui.serviceconnection.authTokenCache import net.mullvad.mullvadvpn.ui.serviceconnection.connectionProxy import net.mullvad.mullvadvpn.usecase.PaymentUseCase +import net.mullvad.mullvadvpn.usecase.OutOfTimeUseCase import net.mullvad.mullvadvpn.usecase.RelayListUseCase import net.mullvad.mullvadvpn.util.appVersionCallbackFlow import net.mullvad.talpid.tunnel.ErrorState @@ -93,6 +94,9 @@ class ConnectViewModelTest { // Payment use case private val mockPaymentUseCase: PaymentUseCase = mockk(relaxed = true) + // Out of time use case + private val mockOutOfTimeUseCase: OutOfTimeUseCase = mockk() + // Captures private val locationSlot = slot<((GeoIpLocation?) -> Unit)>() @@ -102,6 +106,7 @@ class ConnectViewModelTest { // Flows private val selectedRelayFlow = MutableStateFlow(null) + private val outOfTimeViewFlow = MutableStateFlow(false) @Before fun setup() { @@ -135,6 +140,7 @@ class ConnectViewModelTest { // Flows every { mockRelayListUseCase.selectedRelayItem() } returns selectedRelayFlow + every { mockOutOfTimeUseCase.isOutOfTime() } returns outOfTimeViewFlow viewModel = ConnectViewModel( @@ -144,7 +150,8 @@ class ConnectViewModelTest { inAppNotificationController = mockInAppNotificationController, relayListUseCase = mockRelayListUseCase, newDeviceNotificationUseCase = mockk(), - paymentUseCase = mockPaymentUseCase + paymentUseCase = mockPaymentUseCase, + outOfTimeUseCase = mockOutOfTimeUseCase ) } @@ -352,7 +359,7 @@ class ConnectViewModelTest { serviceConnectionState.value = ServiceConnectionState.ConnectedReady(mockServiceConnectionContainer) locationSlot.captured.invoke(mockLocation) - eventNotifierTunnelRealState.notify(tunnelRealStateTestItem) + outOfTimeViewFlow.value = true awaitItem() }