Fix ended poll unit test.

This commit is contained in:
Onuray Sahin 2022-06-27 13:57:35 +03:00
parent a9358e98b2
commit 1a668da077
2 changed files with 25 additions and 6 deletions

View File

@ -119,18 +119,33 @@ class PollItemViewStateFactoryTest {
)
}
/*
@Test
fun `given a sent poll state when poll is closed then PollState is Ended`() = runTest {
fun `given a sent poll state when poll is closed then poll is not votable and option states are Ended`() = runTest {
val closedPollSummary = A_POLL_RESPONSE_DATA.copy(isClosed = true)
val closedPollInformationData = A_MESSAGE_INFORMATION_DATA.copy(pollResponseAggregatedSummary = closedPollSummary)
pollItemViewStateFactory.createPollState(
informationData = A_MESSAGE_INFORMATION_DATA,
pollResponseSummary = closedPollSummary,
val pollViewState = pollItemViewStateFactory.create(
pollContent = A_POLL_CONTENT,
) shouldBe PollState.Ended
informationData = closedPollInformationData,
)
pollViewState shouldBeEqualTo PollViewState(
question = A_POLL_CONTENT.getBestPollCreationInfo()?.question?.getBestQuestion() ?: "",
totalVotes = stringProvider.instance.getQuantityString(R.plurals.poll_total_vote_count_after_ended, 0, 0),
canVote = false,
optionViewStates = A_POLL_CONTENT.getBestPollCreationInfo()?.answers?.map { answer ->
PollOptionViewState.PollEnded(
optionId = answer.id ?: "",
optionAnswer = answer.getBestAnswer() ?: "",
voteCount = 0,
votePercentage = 0.0,
isWinner = false
)
},
)
}
/*
@Test
fun `given a sent poll when undisclosed poll type is selected then PollState is Undisclosed`() = runTest {
pollItemViewStateFactory.createPollState(

View File

@ -27,6 +27,10 @@ class FakeStringProvider {
every { instance.getString(any()) } answers {
"test-${args[0]}"
}
every { instance.getQuantityString(any(), any(), any()) } answers {
"test-${args[0]}-${args[1]}"
}
}
fun given(id: Int, result: String) {