Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
elgatovital committed Aug 29, 2023
1 parent 643f876 commit 1e16f14
Showing 1 changed file with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import org.junit.Rule
import org.junit.Test
import pm.gnosis.model.Solidity
import pm.gnosis.models.Wei
import java.math.BigDecimal
import java.math.BigInteger

class TxReviewViewModelTest {
Expand Down Expand Up @@ -109,7 +110,7 @@ class TxReviewViewModelTest {
}

@Test
fun `updateDefaultKey(different address) emit DefaultKey and track key changed`() {
fun `updateDefaultKey(different address) should emit DefaultKey and track key changed`() {
coEvery { safeRepository.getActiveSafe() } returns TEST_SAFE.apply {
signingOwners = listOf(Solidity.Address(BigInteger.ONE), Solidity.Address(BigInteger.TEN))
}
Expand Down Expand Up @@ -149,7 +150,7 @@ class TxReviewViewModelTest {
}

@Test
fun `updateDefaultKey(same address) emit DefaultKey and not track key changed`() {
fun `updateDefaultKey(same address) should emit DefaultKey and not track key changed`() {
coEvery { safeRepository.getActiveSafe() } returns TEST_SAFE.apply {
signingOwners = listOf(Solidity.Address(BigInteger.ONE), Solidity.Address(BigInteger.TEN))
}
Expand Down Expand Up @@ -191,6 +192,35 @@ class TxReviewViewModelTest {
}
}

@Test
fun `updateEstimationParams should emit UpdateFee`() {
coEvery { safeRepository.getActiveSafe() } returns TEST_SAFE.apply {
signingOwners = listOf(Solidity.Address(BigInteger.ONE), Solidity.Address(BigInteger.TEN))
}
coEvery { tracker.logTxExecFieldsEdit(any()) } just Runs

viewModel = TxReviewViewModel(
safeRepository,
credentialsRepository,
localTxRepository,
settingsHandler,
rpcClient,
balanceFormatter,
tracker,
appDispatchers
)

viewModel.updateEstimationParams(BigInteger.ZERO, BigInteger.ZERO, BigDecimal.ZERO, BigDecimal.ZERO)

with(viewModel.state.test().values()) {
Assert.assertEquals(
UpdateFee(
"0 ${Chain.DEFAULT_CHAIN.currency.symbol}"
), this[0].viewAction
)
}
}

companion object {
val TEST_SAFE = Safe(
Solidity.Address(BigInteger.ZERO),
Expand Down

0 comments on commit 1e16f14

Please sign in to comment.