Test sending option view states.

This commit is contained in:
Onuray Sahin 2022-06-22 14:05:42 +03:00
parent 5a948891f0
commit 2cf40cbcf2
2 changed files with 16 additions and 1 deletions

View File

@ -35,7 +35,6 @@ import im.vector.lib.core.utils.epoxy.charsequence.toEpoxyCharSequence
import org.matrix.android.sdk.api.extensions.orFalse import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.session.room.model.message.MessagePollContent import org.matrix.android.sdk.api.session.room.model.message.MessagePollContent
import org.matrix.android.sdk.api.session.room.model.message.PollAnswer import org.matrix.android.sdk.api.session.room.model.message.PollAnswer
import org.matrix.android.sdk.api.session.room.model.message.PollType
import javax.inject.Inject import javax.inject.Inject
class PollItemFactory @Inject constructor( class PollItemFactory @Inject constructor(

View File

@ -18,6 +18,7 @@ package im.vector.app.features.home.room.detail.timeline.factory
import com.airbnb.mvrx.test.MvRxTestRule import com.airbnb.mvrx.test.MvRxTestRule
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.PollResponseData import im.vector.app.features.home.room.detail.timeline.item.PollResponseData
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
@ -169,4 +170,19 @@ class PollItemFactoryTest {
pollContent = disclosedPollContent, pollContent = disclosedPollContent,
) shouldBe PollState.Ready ) shouldBe PollState.Ready
} }
@Test
fun `given a sending poll then all option view states is PollSending`() = runTest {
with(pollItemFactory) {
A_POLL_CONTENT
.getBestPollCreationInfo()
?.answers
?.mapToOptions(PollState.Sending, A_MESSAGE_INFORMATION_DATA)
?.forEachIndexed { index, pollOptionViewState ->
A_POLL_CONTENT.getBestPollCreationInfo()?.answers?.get(index)?.let { option ->
pollOptionViewState shouldBeEqualTo PollOptionViewState.PollSending(option.id ?: "", option.getBestAnswer() ?: "")
}
}
}
}
} }