|
1 | 1 | package to.bitkit.viewmodels |
2 | 2 |
|
3 | 3 | import android.content.Context |
| 4 | +import app.cash.turbine.test |
4 | 5 | import com.synonym.bitkitcore.LightningInvoice |
5 | 6 | import com.synonym.bitkitcore.NetworkType |
6 | 7 | import com.synonym.bitkitcore.Scanner |
@@ -50,6 +51,7 @@ import to.bitkit.services.AppUpdaterService |
50 | 51 | import to.bitkit.services.CoreService |
51 | 52 | import to.bitkit.services.MigrationService |
52 | 53 | import to.bitkit.test.BaseUnitTest |
| 54 | +import to.bitkit.ui.Routes |
53 | 55 | import to.bitkit.ui.components.Sheet |
54 | 56 | import to.bitkit.ui.shared.toast.ToastQueueManager |
55 | 57 | import to.bitkit.ui.sheets.SendRoute |
@@ -93,6 +95,7 @@ class AppViewModelSendFlowTest : BaseUnitTest() { |
93 | 95 | private val settingsData = MutableStateFlow(SettingsData()) |
94 | 96 | private val walletState = MutableStateFlow(WalletState()) |
95 | 97 | private val nodeEvents = MutableSharedFlow<Event>() |
| 98 | + private val testPublicKey = "pubky3rsduhcxpw74snwyct86m38c63j3pq8x4ycqikxg64roik8yw5xg" |
96 | 99 |
|
97 | 100 | private val timedSheetManager = mock<TimedSheetManager>() |
98 | 101 |
|
@@ -123,6 +126,8 @@ class AppViewModelSendFlowTest : BaseUnitTest() { |
123 | 126 | whenever { widgetsRepo.refreshEnabledWidgets() }.thenReturn(Unit) |
124 | 127 | whenever { lightningRepo.updateGeoBlockState() }.thenReturn(Unit) |
125 | 128 | whenever(pubkyRepo.sessionRestorationFailed).thenReturn(MutableStateFlow(false)) |
| 129 | + whenever(pubkyRepo.publicKey).thenReturn(MutableStateFlow(null)) |
| 130 | + whenever(pubkyRepo.contacts).thenReturn(MutableStateFlow(emptyList())) |
126 | 131 | whenever(currencyRepo.convertSatsToFiat(any(), anyOrNull())) |
127 | 132 | .thenReturn(Result.failure(Exception("not mocked"))) |
128 | 133 | whenever { lightningRepo.calculateTotalFee(any(), anyOrNull(), any(), anyOrNull(), anyOrNull()) } |
@@ -218,6 +223,15 @@ class AppViewModelSendFlowTest : BaseUnitTest() { |
218 | 223 | assertFalse(sut.sendUiState.value.canSwitchWallet) |
219 | 224 | } |
220 | 225 |
|
| 226 | + @Test |
| 227 | + fun `manual address continue routes pubky to add contact`() = test { |
| 228 | + sut.mainScreenEffect.test { |
| 229 | + sut.setSendEvent(SendEvent.AddressContinue(testPublicKey)) |
| 230 | + |
| 231 | + assertEquals(MainScreenEffect.Navigate(Routes.AddContact(testPublicKey)), awaitItem()) |
| 232 | + } |
| 233 | + } |
| 234 | + |
221 | 235 | @Test |
222 | 236 | fun `canSwitchWallet is false when amount exceeds lightning balance`() = test { |
223 | 237 | balanceState.value = BalanceState( |
|
0 commit comments