Render only winner options in past poll list
This commit is contained in:
parent
d3df58c607
commit
922b8092ac
@ -69,7 +69,9 @@ class PollSummaryMapper @Inject constructor(
|
|||||||
creationTimestamp = creationTimestamp,
|
creationTimestamp = creationTimestamp,
|
||||||
title = pollTitle,
|
title = pollTitle,
|
||||||
totalVotes = pollResponseData.totalVotes,
|
totalVotes = pollResponseData.totalVotes,
|
||||||
winnerOptions = pollOptionViewStateFactory.createPollEndedOptions(pollCreationInfo, pollResponseData),
|
winnerOptions = pollOptionViewStateFactory
|
||||||
|
.createPollEndedOptions(pollCreationInfo, pollResponseData)
|
||||||
|
.filter { it.isWinner },
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
PollSummary.ActivePoll(
|
PollSummary.ActivePoll(
|
||||||
|
@ -84,10 +84,12 @@ internal class PollSummaryMapperTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `given an ended poll event when mapping to model then result is ended poll`() {
|
fun `given an ended poll event when mapping to model then result is ended poll with only winner options`() {
|
||||||
// Given
|
// Given
|
||||||
val totalVotes = 10
|
val totalVotes = 10
|
||||||
val winnerOptions = listOf<PollOptionViewState.PollEnded>()
|
val option1 = givenAPollEndedOption(isWinner = false)
|
||||||
|
val option2 = givenAPollEndedOption(isWinner = true)
|
||||||
|
val winnerOptions = listOf(option1, option2)
|
||||||
val endedPollEvent = givenAPollTimelineEvent(
|
val endedPollEvent = givenAPollTimelineEvent(
|
||||||
eventId = AN_EVENT_ID,
|
eventId = AN_EVENT_ID,
|
||||||
creationTimestamp = AN_EVENT_TIMESTAMP,
|
creationTimestamp = AN_EVENT_TIMESTAMP,
|
||||||
@ -101,7 +103,7 @@ internal class PollSummaryMapperTest {
|
|||||||
creationTimestamp = AN_EVENT_TIMESTAMP,
|
creationTimestamp = AN_EVENT_TIMESTAMP,
|
||||||
title = A_POLL_TITLE,
|
title = A_POLL_TITLE,
|
||||||
totalVotes = totalVotes,
|
totalVotes = totalVotes,
|
||||||
winnerOptions = winnerOptions,
|
winnerOptions = listOf(option2),
|
||||||
)
|
)
|
||||||
|
|
||||||
// When
|
// When
|
||||||
@ -198,4 +200,10 @@ internal class PollSummaryMapperTest {
|
|||||||
totalVotes = totalVotes,
|
totalVotes = totalVotes,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun givenAPollEndedOption(isWinner: Boolean): PollOptionViewState.PollEnded {
|
||||||
|
return mockk<PollOptionViewState.PollEnded>().also {
|
||||||
|
every { it.isWinner } returns isWinner
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user