Skip to content

Commit

Permalink
Fix connect view model tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pururun committed Nov 29, 2023
1 parent 0e473b9 commit eb093c1
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)>()

Expand All @@ -102,6 +106,7 @@ class ConnectViewModelTest {

// Flows
private val selectedRelayFlow = MutableStateFlow<RelayItem?>(null)
private val outOfTimeViewFlow = MutableStateFlow(false)

@Before
fun setup() {
Expand Down Expand Up @@ -135,6 +140,7 @@ class ConnectViewModelTest {

// Flows
every { mockRelayListUseCase.selectedRelayItem() } returns selectedRelayFlow
every { mockOutOfTimeUseCase.isOutOfTime() } returns outOfTimeViewFlow

viewModel =
ConnectViewModel(
Expand All @@ -144,7 +150,8 @@ class ConnectViewModelTest {
inAppNotificationController = mockInAppNotificationController,
relayListUseCase = mockRelayListUseCase,
newDeviceNotificationUseCase = mockk(),
paymentUseCase = mockPaymentUseCase
paymentUseCase = mockPaymentUseCase,
outOfTimeUseCase = mockOutOfTimeUseCase
)
}

Expand Down Expand Up @@ -352,7 +359,7 @@ class ConnectViewModelTest {
serviceConnectionState.value =
ServiceConnectionState.ConnectedReady(mockServiceConnectionContainer)
locationSlot.captured.invoke(mockLocation)
eventNotifierTunnelRealState.notify(tunnelRealStateTestItem)
outOfTimeViewFlow.value = true
awaitItem()
}

Expand Down

0 comments on commit eb093c1

Please sign in to comment.