mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2024-09-29 08:20:51 +00:00
Rename UserZaps.forProfileFeed()
This commit is contained in:
parent
6aa7c229b0
commit
1424267628
@ -4,7 +4,7 @@ import com.vitorpamplona.amethyst.model.Note
|
||||
import com.vitorpamplona.amethyst.service.model.LnZapEventInterface
|
||||
|
||||
object UserZaps {
|
||||
fun groupByUser(zaps: Map<Note, Note?>?): List<Pair<Note, Note>> {
|
||||
fun forProfileFeed(zaps: Map<Note, Note?>?): List<Pair<Note, Note>> {
|
||||
if (zaps == null) return emptyList()
|
||||
|
||||
return (zaps
|
||||
|
@ -13,6 +13,6 @@ object UserProfileZapsFeedFilter: FeedFilter<Pair<Note, Note>>() {
|
||||
}
|
||||
|
||||
override fun feed(): List<Pair<Note, Note>> {
|
||||
return UserZaps.groupByUser(user?.zaps)
|
||||
return UserZaps.forProfileFeed(user?.zaps)
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class UserZapsTest {
|
||||
|
||||
@Test
|
||||
fun user_without_zaps() {
|
||||
val actual = UserZaps.groupByUser(zaps = null)
|
||||
val actual = UserZaps.forProfileFeed(zaps = null)
|
||||
|
||||
Assert.assertEquals(emptyList<Pair<Note, Note>>(), actual)
|
||||
}
|
||||
@ -32,7 +32,7 @@ class UserZapsTest {
|
||||
zapRequest to mockZapNoteWith("user-1", amount = 200),
|
||||
)
|
||||
|
||||
val actual = UserZaps.groupByUser(zaps)
|
||||
val actual = UserZaps.forProfileFeed(zaps)
|
||||
|
||||
Assert.assertEquals(1, actual.count())
|
||||
Assert.assertEquals(zapRequest, actual.first().first)
|
||||
@ -42,29 +42,6 @@ class UserZapsTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aggregate_zap_amount_group_by_user() {
|
||||
val zaps: Map<Note, Note?> = mapOf(
|
||||
mockk<Note>() to mockZapNoteWith("user-1", amount = 100),
|
||||
mockk<Note>() to mockZapNoteWith("user-1", amount = 200),
|
||||
mockk<Note>() to mockZapNoteWith("user-2", amount = 400),
|
||||
)
|
||||
|
||||
val actual = UserZaps.groupByUser(zaps)
|
||||
|
||||
Assert.assertEquals(2, actual.count())
|
||||
|
||||
Assert.assertEquals(
|
||||
BigDecimal(300),
|
||||
(actual[0].second.event as LnZapEventInterface).amount()
|
||||
)
|
||||
|
||||
Assert.assertEquals(
|
||||
BigDecimal(400),
|
||||
(actual[1].second.event as LnZapEventInterface).amount()
|
||||
)
|
||||
}
|
||||
|
||||
private fun mockZapNoteWith(pubkey: HexKey, amount: Int): Note {
|
||||
|
||||
val lnZapEvent = mockk<LnZapEventInterface>()
|
||||
|
Loading…
Reference in New Issue
Block a user