Updated on 2026-08-14
This commit is contained in:
parent
00974e5d3d
commit
2cc7fdc952
2 changed files with 40 additions and 1 deletions
|
|
@ -47,8 +47,9 @@ internal class WalletAccountListFlowFactory @Inject constructor(
|
|||
|
||||
return accountsResponseStoreFactory.create(userWallet.walletId).data
|
||||
.filterNotNull()
|
||||
.filter { it.accounts.isNotEmpty() }
|
||||
.distinctUntilChanged()
|
||||
.map(converter::convert)
|
||||
.map { converter.convert(it) }
|
||||
}
|
||||
|
||||
private fun createForSingleWallet(userWallet: UserWallet): AccountList {
|
||||
|
|
|
|||
|
|
@ -169,4 +169,42 @@ class WalletAccountListFlowFactoryTest {
|
|||
accountListConverter.convert(any())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `create for multi wallet with empty accounts does not emit`() = runTest {
|
||||
// Arrange
|
||||
val userWallet = mockk<UserWallet> {
|
||||
every { this@mockk.walletId } returns userWalletId
|
||||
every { this@mockk.isMultiCurrency } returns true
|
||||
}
|
||||
|
||||
val userWalletsFlow = MutableStateFlow(listOf(userWallet))
|
||||
|
||||
every { userWalletsListRepository.userWallets } returns userWalletsFlow
|
||||
|
||||
val accountsResponseWithEmptyAccounts = GetWalletAccountsResponse(
|
||||
wallet = GetWalletAccountsResponse.Wallet(
|
||||
group = null,
|
||||
sort = null,
|
||||
totalAccounts = 0,
|
||||
totalArchivedAccounts = 0,
|
||||
),
|
||||
accounts = emptyList(),
|
||||
unassignedTokens = emptyList(),
|
||||
)
|
||||
every { accountsResponseStoreFactory.create(userWalletId) } returns accountsResponseStore
|
||||
every { accountsResponseStore.data } returns accountsResponseStoreFlow
|
||||
accountsResponseStoreFlow.value = accountsResponseWithEmptyAccounts
|
||||
|
||||
// Act
|
||||
val actual = factory.create(userWalletId).let(::getEmittedValues)
|
||||
|
||||
// Assert
|
||||
Truth.assertThat(actual).isEmpty()
|
||||
|
||||
coVerify(inverse = true) {
|
||||
accountListConverterFactory.create(any())
|
||||
accountListConverter.convert(any())
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue