From 2cc7fdc952b80ca97b42f2717811e44770ce72d7 Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 16 Feb 2026 14:16:56 +0400 Subject: [PATCH] Updated on 2026-08-14 --- .../producer/WalletAccountListFlowFactory.kt | 3 +- .../WalletAccountListFlowFactoryTest.kt | 38 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/data/account/src/main/kotlin/com/tangem/data/account/producer/WalletAccountListFlowFactory.kt b/data/account/src/main/kotlin/com/tangem/data/account/producer/WalletAccountListFlowFactory.kt index 2fe0b92a3f..fbc60cc6c6 100644 --- a/data/account/src/main/kotlin/com/tangem/data/account/producer/WalletAccountListFlowFactory.kt +++ b/data/account/src/main/kotlin/com/tangem/data/account/producer/WalletAccountListFlowFactory.kt @@ -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 { diff --git a/data/account/src/test/java/com/tangem/data/account/producer/WalletAccountListFlowFactoryTest.kt b/data/account/src/test/java/com/tangem/data/account/producer/WalletAccountListFlowFactoryTest.kt index bcda235987..335516f9fd 100644 --- a/data/account/src/test/java/com/tangem/data/account/producer/WalletAccountListFlowFactoryTest.kt +++ b/data/account/src/test/java/com/tangem/data/account/producer/WalletAccountListFlowFactoryTest.kt @@ -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 { + 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()) + } + } } \ No newline at end of file