diff options
| author | David Göransson <david.goransson@mullvad.net> | 2024-03-11 13:26:33 +0100 |
|---|---|---|
| committer | David Göransson <david.goransson@mullvad.net> | 2024-03-11 15:56:57 +0100 |
| commit | c6b1744b673644eaec26c93da9beadec4344a575 (patch) | |
| tree | 92c296ac643d3e5061434138279bfa1ddd208c31 /android/app/src/test | |
| parent | 5560072b52fd1fc883ce3864328c5751ac778528 (diff) | |
| download | mullvadvpn-c6b1744b673644eaec26c93da9beadec4344a575.tar.xz mullvadvpn-c6b1744b673644eaec26c93da9beadec4344a575.zip | |
Revert navigation logic on Welcome to handle bad clocks better
Diffstat (limited to 'android/app/src/test')
| -rw-r--r-- | android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/WelcomeViewModelTest.kt | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/WelcomeViewModelTest.kt b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/WelcomeViewModelTest.kt index c52dd3a103..91554193bc 100644 --- a/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/WelcomeViewModelTest.kt +++ b/android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/WelcomeViewModelTest.kt @@ -32,11 +32,9 @@ import net.mullvad.mullvadvpn.ui.serviceconnection.ServiceConnectionContainer import net.mullvad.mullvadvpn.ui.serviceconnection.ServiceConnectionManager import net.mullvad.mullvadvpn.ui.serviceconnection.ServiceConnectionState import net.mullvad.mullvadvpn.ui.serviceconnection.authTokenCache -import net.mullvad.mullvadvpn.usecase.OutOfTimeUseCase import net.mullvad.mullvadvpn.usecase.PaymentUseCase import net.mullvad.talpid.util.EventNotifier import org.joda.time.DateTime -import org.joda.time.ReadableInstant import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -51,7 +49,6 @@ class WelcomeViewModelTest { private val accountExpiryStateFlow = MutableStateFlow<AccountExpiry>(AccountExpiry.Missing) private val purchaseResultFlow = MutableStateFlow<PurchaseResult?>(null) private val paymentAvailabilityFlow = MutableStateFlow<PaymentAvailability?>(null) - private val outOfTimeFlow = MutableStateFlow(true) // Service connections private val mockServiceConnectionContainer: ServiceConnectionContainer = mockk() @@ -64,7 +61,6 @@ class WelcomeViewModelTest { private val mockDeviceRepository: DeviceRepository = mockk() private val mockServiceConnectionManager: ServiceConnectionManager = mockk() private val mockPaymentUseCase: PaymentUseCase = mockk(relaxed = true) - private val mockOutOfTimeUseCase: OutOfTimeUseCase = mockk(relaxed = true) private lateinit var viewModel: WelcomeViewModel @@ -87,15 +83,12 @@ class WelcomeViewModelTest { coEvery { mockPaymentUseCase.paymentAvailability } returns paymentAvailabilityFlow - coEvery { mockOutOfTimeUseCase.isOutOfTime } returns outOfTimeFlow - viewModel = WelcomeViewModel( accountRepository = mockAccountRepository, deviceRepository = mockDeviceRepository, serviceConnectionManager = mockServiceConnectionManager, paymentUseCase = mockPaymentUseCase, - outOfTimeUseCase = mockOutOfTimeUseCase, pollAccountExpiry = false, isPlayBuild = false ) @@ -164,19 +157,16 @@ class WelcomeViewModelTest { } @Test - fun `when OutOfTimeUseCase return false uiSideEffect should emit OpenConnectScreen`() = - runTest { - // Arrange - val mockExpiryDate: DateTime = mockk() - every { mockExpiryDate.isAfter(any<ReadableInstant>()) } returns true + fun `when user has added time then uiSideEffect should emit OpenConnectScreen`() = runTest { + // Arrange + accountExpiryStateFlow.emit(AccountExpiry.Available(DateTime().plusDays(1))) - // Act, Assert - viewModel.uiSideEffect.test { - outOfTimeFlow.value = false - val action = awaitItem() - assertIs<WelcomeViewModel.UiSideEffect.OpenConnectScreen>(action) - } + // Act, Assert + viewModel.uiSideEffect.test { + val action = awaitItem() + assertIs<WelcomeViewModel.UiSideEffect.OpenConnectScreen>(action) } + } @Test fun `when paymentAvailability emits ProductsUnavailable uiState should include state NoPayment`() = |
