mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-26 09:33:14 +01:00
Fix voted poll unit test.
This commit is contained in:
parent
6f4e079a2e
commit
d7c2dbe83f
@ -21,6 +21,7 @@ import im.vector.app.R
|
|||||||
import im.vector.app.features.home.room.detail.timeline.item.MessageInformationData
|
import im.vector.app.features.home.room.detail.timeline.item.MessageInformationData
|
||||||
import im.vector.app.features.home.room.detail.timeline.item.PollOptionViewState
|
import im.vector.app.features.home.room.detail.timeline.item.PollOptionViewState
|
||||||
import im.vector.app.features.home.room.detail.timeline.item.PollResponseData
|
import im.vector.app.features.home.room.detail.timeline.item.PollResponseData
|
||||||
|
import im.vector.app.features.home.room.detail.timeline.item.PollVoteSummaryData
|
||||||
import im.vector.app.features.home.room.detail.timeline.item.ReactionsSummaryData
|
import im.vector.app.features.home.room.detail.timeline.item.ReactionsSummaryData
|
||||||
import im.vector.app.features.home.room.detail.timeline.style.TimelineMessageLayout
|
import im.vector.app.features.home.room.detail.timeline.style.TimelineMessageLayout
|
||||||
import im.vector.app.features.poll.PollViewState
|
import im.vector.app.features.poll.PollViewState
|
||||||
@ -54,6 +55,8 @@ private val A_POLL_RESPONSE_DATA = PollResponseData(
|
|||||||
votes = emptyMap(),
|
votes = emptyMap(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private val A_POLL_OPTION_IDS = listOf("5ef5f7b0-c9a1-49cf-a0b3-374729a43e76", "ec1a4db0-46d8-4d7a-9bb6-d80724715938", "3677ca8e-061b-40ab-bffe-b22e4e88fcad")
|
||||||
|
|
||||||
private val A_POLL_CONTENT = MessagePollContent(
|
private val A_POLL_CONTENT = MessagePollContent(
|
||||||
unstablePollCreationInfo = PollCreationInfo(
|
unstablePollCreationInfo = PollCreationInfo(
|
||||||
question = PollQuestion(
|
question = PollQuestion(
|
||||||
@ -63,15 +66,15 @@ private val A_POLL_CONTENT = MessagePollContent(
|
|||||||
maxSelections = 1,
|
maxSelections = 1,
|
||||||
answers = listOf(
|
answers = listOf(
|
||||||
PollAnswer(
|
PollAnswer(
|
||||||
id = "5ef5f7b0-c9a1-49cf-a0b3-374729a43e76",
|
id = A_POLL_OPTION_IDS[0],
|
||||||
unstableAnswer = "Double Espresso"
|
unstableAnswer = "Double Espresso"
|
||||||
),
|
),
|
||||||
PollAnswer(
|
PollAnswer(
|
||||||
id = "ec1a4db0-46d8-4d7a-9bb6-d80724715938",
|
id =A_POLL_OPTION_IDS[1],
|
||||||
unstableAnswer = "Macchiato"
|
unstableAnswer = "Macchiato"
|
||||||
),
|
),
|
||||||
PollAnswer(
|
PollAnswer(
|
||||||
id = "3677ca8e-061b-40ab-bffe-b22e4e88fcad",
|
id = A_POLL_OPTION_IDS[2],
|
||||||
unstableAnswer = "Iced Coffee"
|
unstableAnswer = "Iced Coffee"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -166,26 +169,42 @@ class PollItemViewStateFactoryTest {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
@Test
|
@Test
|
||||||
fun `given a sent poll when my vote exists then PollState is Voted`() = runTest {
|
fun `given a sent poll when my vote exists then poll is still votable and options states are PollVoted`() = runTest {
|
||||||
val votedPollData = A_POLL_RESPONSE_DATA.copy(
|
val votedPollData = A_POLL_RESPONSE_DATA.copy(
|
||||||
totalVotes = 1,
|
totalVotes = 1,
|
||||||
myVote = "5ef5f7b0-c9a1-49cf-a0b3-374729a43e76",
|
myVote = A_POLL_OPTION_IDS[0],
|
||||||
|
votes = mapOf(A_POLL_OPTION_IDS[0] to PollVoteSummaryData(total = 1, percentage = 1.0))
|
||||||
)
|
)
|
||||||
val disclosedPollContent = A_POLL_CONTENT.copy(
|
val disclosedPollContent = A_POLL_CONTENT.copy(
|
||||||
unstablePollCreationInfo = A_POLL_CONTENT.getBestPollCreationInfo()?.copy(
|
unstablePollCreationInfo = A_POLL_CONTENT.getBestPollCreationInfo()?.copy(
|
||||||
kind = PollType.DISCLOSED_UNSTABLE
|
kind = PollType.DISCLOSED_UNSTABLE
|
||||||
)
|
),
|
||||||
|
)
|
||||||
|
val votedInformationData = A_MESSAGE_INFORMATION_DATA.copy(pollResponseAggregatedSummary = votedPollData)
|
||||||
|
|
||||||
|
val pollViewState = pollItemViewStateFactory.create(
|
||||||
|
pollContent = disclosedPollContent,
|
||||||
|
informationData = votedInformationData,
|
||||||
)
|
)
|
||||||
|
|
||||||
pollItemViewStateFactory.createPollState(
|
pollViewState shouldBeEqualTo PollViewState(
|
||||||
informationData = A_MESSAGE_INFORMATION_DATA,
|
question = A_POLL_CONTENT.getBestPollCreationInfo()?.question?.getBestQuestion() ?: "",
|
||||||
pollResponseSummary = votedPollData,
|
totalVotes = stringProvider.instance.getQuantityString(R.plurals.poll_total_vote_count_before_ended_and_voted, 1, 1),
|
||||||
pollContent = disclosedPollContent,
|
canVote = true,
|
||||||
) shouldBeEqualTo PollState.Voted(1)
|
optionViewStates = A_POLL_CONTENT.getBestPollCreationInfo()?.answers?.mapIndexed { index, answer ->
|
||||||
|
PollOptionViewState.PollVoted(
|
||||||
|
optionId = answer.id ?: "",
|
||||||
|
optionAnswer = answer.getBestAnswer() ?: "",
|
||||||
|
voteCount = if (index == 0) 1 else 0,
|
||||||
|
votePercentage = if (index == 0) 1.0 else 0.0,
|
||||||
|
isSelected = index == 0
|
||||||
|
)
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
@Test
|
@Test
|
||||||
fun `given a sent poll when poll type is disclosed then PollState is Ready`() = runTest {
|
fun `given a sent poll when poll type is disclosed then PollState is Ready`() = runTest {
|
||||||
val disclosedPollContent = A_POLL_CONTENT.copy(
|
val disclosedPollContent = A_POLL_CONTENT.copy(
|
||||||
|
Loading…
Reference in New Issue
Block a user