@@ -6,14 +6,13 @@ import androidx.compose.ui.test.onNodeWithTag
66import androidx.compose.ui.test.performClick
77import org.junit.Rule
88import org.junit.Test
9- import to.bitkit.models.BitcoinDisplayUnit
109import to.bitkit.models.NodeLifecycleState
1110import to.bitkit.models.PrimaryDisplay
12- import to.bitkit.viewmodels.CurrencyUiState
11+ import to.bitkit.repositories.CurrencyState
1312import to.bitkit.viewmodels.MainUiState
14- import to.bitkit.viewmodels.SendEvent
1513import to.bitkit.viewmodels.SendMethod
1614import to.bitkit.viewmodels.SendUiState
15+ import to.bitkit.viewmodels.previewAmountInputViewModel
1716
1817class SendAmountContentTest {
1918
@@ -22,8 +21,7 @@ class SendAmountContentTest {
2221
2322 private val testUiState = SendUiState (
2423 payMethod = SendMethod .LIGHTNING ,
25- amountInput = " 100" ,
26- isAmountInputValid = true ,
24+ amount = 100u ,
2725 isUnified = true
2826 )
2927
@@ -35,21 +33,15 @@ class SendAmountContentTest {
3533 fun whenScreenLoaded_shouldShowAllComponents () {
3634 composeTestRule.setContent {
3735 SendAmountContent (
38- input = " 100" ,
39- uiState = testUiState,
4036 walletUiState = testWalletState,
41- currencyUiState = CurrencyUiState (primaryDisplay = PrimaryDisplay .BITCOIN ),
42- displayUnit = BitcoinDisplayUnit .MODERN ,
43- primaryDisplay = PrimaryDisplay .BITCOIN ,
44- onInputChanged = {},
45- onEvent = {},
46- onBack = {}
37+ uiState = testUiState,
38+ amountInputViewModel = previewAmountInputViewModel(),
4739 )
4840 }
4941
5042 composeTestRule.onNodeWithTag(" send_amount_screen" ).assertExists()
51- // composeTestRule.onNodeWithTag("amount_input_field ").assertExists() doesn't displayed because of viewmodel injection
52- composeTestRule.onNodeWithTag(" available_balance" ).assertExists()
43+ composeTestRule.onNodeWithTag(" SendNumberField " ).assertExists()
44+ composeTestRule.onNodeWithTag(" available_balance" , useUnmergedTree = true ).assertExists()
5345 composeTestRule.onNodeWithTag(" AssetButton-switch" ).assertExists()
5446 composeTestRule.onNodeWithTag(" ContinueAmount" ).assertExists()
5547 composeTestRule.onNodeWithTag(" SendAmountNumberPad" ).assertExists()
@@ -59,42 +51,27 @@ class SendAmountContentTest {
5951 fun whenNodeNotRunning_shouldShowSyncView () {
6052 composeTestRule.setContent {
6153 SendAmountContent (
62- input = " 100" ,
63- uiState = testUiState,
6454 walletUiState = MainUiState (
6555 nodeLifecycleState = NodeLifecycleState .Initializing
6656 ),
67- displayUnit = BitcoinDisplayUnit .MODERN ,
68- primaryDisplay = PrimaryDisplay .BITCOIN ,
69- currencyUiState = CurrencyUiState (),
70- onInputChanged = {},
71- onEvent = {},
72- onBack = {}
57+ uiState = testUiState,
58+ amountInputViewModel = previewAmountInputViewModel(),
7359 )
7460 }
7561
7662 composeTestRule.onNodeWithTag(" sync_node_view" ).assertExists()
77- composeTestRule.onNodeWithTag(" amount_input_field " ).assertDoesNotExist()
63+ composeTestRule.onNodeWithTag(" SendNumberField " ).assertDoesNotExist()
7864 }
7965
8066 @Test
8167 fun whenPaymentMethodButtonClicked_shouldTriggerEvent () {
8268 var eventTriggered = false
8369 composeTestRule.setContent {
8470 SendAmountContent (
85- input = " 100" ,
86- uiState = testUiState,
8771 walletUiState = testWalletState,
88- currencyUiState = CurrencyUiState (),
89- onInputChanged = {},
90- onEvent = { event ->
91- if (event is SendEvent .PaymentMethodSwitch ) {
92- eventTriggered = true
93- }
94- },
95- displayUnit = BitcoinDisplayUnit .MODERN ,
96- primaryDisplay = PrimaryDisplay .BITCOIN ,
97- onBack = {}
72+ uiState = testUiState,
73+ amountInputViewModel = previewAmountInputViewModel(),
74+ onClickPayMethod = { eventTriggered = true }
9875 )
9976 }
10077
@@ -109,23 +86,14 @@ class SendAmountContentTest {
10986 var eventTriggered = false
11087 composeTestRule.setContent {
11188 SendAmountContent (
112- input = " 100" ,
113- uiState = testUiState.copy(isAmountInputValid = true ),
11489 walletUiState = testWalletState,
115- currencyUiState = CurrencyUiState (),
116- onInputChanged = {},
117- onEvent = { event ->
118- if (event is SendEvent .AmountContinue ) {
119- eventTriggered = true
120- }
121- },
122- displayUnit = BitcoinDisplayUnit .MODERN ,
123- primaryDisplay = PrimaryDisplay .BITCOIN ,
124- onBack = {}
90+ uiState = testUiState,
91+ amountInputViewModel = previewAmountInputViewModel(),
92+ onContinue = { eventTriggered = true }
12593 )
12694 }
12795
128- composeTestRule.onNodeWithTag(" continue_button " )
96+ composeTestRule.onNodeWithTag(" ContinueAmount " )
12997 .performClick()
13098
13199 assert (eventTriggered)
@@ -135,18 +103,12 @@ class SendAmountContentTest {
135103 fun whenAmountInvalid_continueButtonShouldBeDisabled () {
136104 composeTestRule.setContent {
137105 SendAmountContent (
138- input = " 100" ,
139- uiState = testUiState.copy(isAmountInputValid = false ),
140106 walletUiState = testWalletState,
141- currencyUiState = CurrencyUiState (),
142- onInputChanged = {},
143- onEvent = {},
144- displayUnit = BitcoinDisplayUnit .MODERN ,
145- primaryDisplay = PrimaryDisplay .BITCOIN ,
146- onBack = {}
107+ uiState = testUiState.copy(amount = 0u ),
108+ amountInputViewModel = previewAmountInputViewModel(),
147109 )
148110 }
149111
150- composeTestRule.onNodeWithTag(" continue_button " ).assertIsNotEnabled()
112+ composeTestRule.onNodeWithTag(" ContinueAmount " ).assertIsNotEnabled()
151113 }
152114}
0 commit comments