Updated on 2026-08-14
This commit is contained in:
parent
a0f6e4a008
commit
6c8b59c569
12 changed files with 288 additions and 66 deletions
|
|
@ -44,14 +44,6 @@ internal class DefaultNotificationsRepository @Inject constructor(
|
|||
return appPreferencesStore.getSyncOrNull(PreferencesKeys.NOTIFICATIONS_APPLICATION_ID_KEY)
|
||||
}
|
||||
|
||||
override suspend fun setNotificationsEnabledForWallet(walletId: String, enabled: Boolean) =
|
||||
withContext(dispatchers.io) {
|
||||
tangemTechApi.setNotificationsEnabled(
|
||||
walletId = walletId,
|
||||
body = WalletBody(notifyStatus = enabled),
|
||||
).getOrThrow()
|
||||
}
|
||||
|
||||
override suspend fun associateApplicationIdWithWallets(appId: String, wallets: List<String>) =
|
||||
withContext(dispatchers.io) {
|
||||
tangemTechApi.associateApplicationIdWithWallets(
|
||||
|
|
@ -62,10 +54,6 @@ internal class DefaultNotificationsRepository @Inject constructor(
|
|||
).getOrThrow()
|
||||
}
|
||||
|
||||
override suspend fun isNotificationsEnabledForWallet(walletId: String): Boolean = withContext(dispatchers.io) {
|
||||
tangemTechApi.getWalletById(walletId).getOrThrow().notifyStatus
|
||||
}
|
||||
|
||||
override suspend fun setWalletName(walletId: String, walletName: String) = withContext(dispatchers.io) {
|
||||
tangemTechApi.updateWallet(
|
||||
walletId,
|
||||
|
|
|
|||
|
|
@ -103,26 +103,6 @@ class DefaultNotificationsRepositoryTest {
|
|||
assertThat(result).isEqualTo(expectedAppId)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN wallet id and enabled status WHEN setNotificationsEnabledForWallet THEN updates notification status`() =
|
||||
runTest {
|
||||
// GIVEN
|
||||
val walletId = "test-wallet-id"
|
||||
val enabled = true
|
||||
coEvery {
|
||||
tangemTechApi.setNotificationsEnabled(
|
||||
walletId,
|
||||
WalletBody(notifyStatus = enabled),
|
||||
)
|
||||
} returns ApiResponse.Success(Unit)
|
||||
|
||||
// WHEN
|
||||
repository.setNotificationsEnabledForWallet(walletId, enabled)
|
||||
|
||||
// THEN
|
||||
coVerify { tangemTechApi.setNotificationsEnabled(walletId, WalletBody(notifyStatus = enabled)) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN application id and wallet list WHEN associateApplicationIdWithWallets THEN associates them`() = runTest {
|
||||
// GIVEN
|
||||
|
|
@ -142,26 +122,6 @@ class DefaultNotificationsRepositoryTest {
|
|||
coVerify { tangemTechApi.associateApplicationIdWithWallets(appId, wallets.map { WalletIdBody(it) }) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN wallet id WHEN isNotificationsEnabledForWallet THEN returns notification status`() = runTest {
|
||||
// GIVEN
|
||||
val walletId = "test-wallet-id"
|
||||
val expectedStatus = true
|
||||
coEvery { tangemTechApi.getWalletById(walletId) } returns ApiResponse.Success(
|
||||
WalletResponse(
|
||||
notifyStatus = expectedStatus,
|
||||
name = "Test Wallet",
|
||||
id = walletId,
|
||||
),
|
||||
)
|
||||
|
||||
// WHEN
|
||||
val result = repository.isNotificationsEnabledForWallet(walletId)
|
||||
|
||||
// THEN
|
||||
assertThat(result).isEqualTo(expectedStatus)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN wallet id and name WHEN setWalletName THEN updates wallet name`() = runTest {
|
||||
// GIVEN
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue