@@ -32,11 +32,9 @@ import net.mullvad.mullvadvpn.ui.serviceconnection.ServiceConnectionContainer
32
32
import net.mullvad.mullvadvpn.ui.serviceconnection.ServiceConnectionManager
33
33
import net.mullvad.mullvadvpn.ui.serviceconnection.ServiceConnectionState
34
34
import net.mullvad.mullvadvpn.ui.serviceconnection.authTokenCache
35
- import net.mullvad.mullvadvpn.usecase.OutOfTimeUseCase
36
35
import net.mullvad.mullvadvpn.usecase.PaymentUseCase
37
36
import net.mullvad.talpid.util.EventNotifier
38
37
import org.joda.time.DateTime
39
- import org.joda.time.ReadableInstant
40
38
import org.junit.jupiter.api.AfterEach
41
39
import org.junit.jupiter.api.BeforeEach
42
40
import org.junit.jupiter.api.Test
@@ -51,7 +49,6 @@ class WelcomeViewModelTest {
51
49
private val accountExpiryStateFlow = MutableStateFlow <AccountExpiry >(AccountExpiry .Missing )
52
50
private val purchaseResultFlow = MutableStateFlow <PurchaseResult ?>(null )
53
51
private val paymentAvailabilityFlow = MutableStateFlow <PaymentAvailability ?>(null )
54
- private val outOfTimeFlow = MutableStateFlow (true )
55
52
56
53
// Service connections
57
54
private val mockServiceConnectionContainer: ServiceConnectionContainer = mockk()
@@ -64,7 +61,6 @@ class WelcomeViewModelTest {
64
61
private val mockDeviceRepository: DeviceRepository = mockk()
65
62
private val mockServiceConnectionManager: ServiceConnectionManager = mockk()
66
63
private val mockPaymentUseCase: PaymentUseCase = mockk(relaxed = true )
67
- private val mockOutOfTimeUseCase: OutOfTimeUseCase = mockk(relaxed = true )
68
64
69
65
private lateinit var viewModel: WelcomeViewModel
70
66
@@ -87,15 +83,12 @@ class WelcomeViewModelTest {
87
83
88
84
coEvery { mockPaymentUseCase.paymentAvailability } returns paymentAvailabilityFlow
89
85
90
- coEvery { mockOutOfTimeUseCase.isOutOfTime } returns outOfTimeFlow
91
-
92
86
viewModel =
93
87
WelcomeViewModel (
94
88
accountRepository = mockAccountRepository,
95
89
deviceRepository = mockDeviceRepository,
96
90
serviceConnectionManager = mockServiceConnectionManager,
97
91
paymentUseCase = mockPaymentUseCase,
98
- outOfTimeUseCase = mockOutOfTimeUseCase,
99
92
pollAccountExpiry = false ,
100
93
isPlayBuild = false
101
94
)
@@ -164,19 +157,16 @@ class WelcomeViewModelTest {
164
157
}
165
158
166
159
@Test
167
- fun `when OutOfTimeUseCase return false uiSideEffect should emit OpenConnectScreen` () =
168
- runTest {
169
- // Arrange
170
- val mockExpiryDate: DateTime = mockk()
171
- every { mockExpiryDate.isAfter(any<ReadableInstant >()) } returns true
160
+ fun `when user has added time then uiSideEffect should emit OpenConnectScreen` () = runTest {
161
+ // Arrange
162
+ accountExpiryStateFlow.emit(AccountExpiry .Available (DateTime ().plusDays(1 )))
172
163
173
- // Act, Assert
174
- viewModel.uiSideEffect.test {
175
- outOfTimeFlow.value = false
176
- val action = awaitItem()
177
- assertIs<WelcomeViewModel .UiSideEffect .OpenConnectScreen >(action)
178
- }
164
+ // Act, Assert
165
+ viewModel.uiSideEffect.test {
166
+ val action = awaitItem()
167
+ assertIs<WelcomeViewModel .UiSideEffect .OpenConnectScreen >(action)
179
168
}
169
+ }
180
170
181
171
@Test
182
172
fun `when paymentAvailability emits ProductsUnavailable uiState should include state NoPayment` () =
0 commit comments