Test ended poll state.

This commit is contained in:
Onuray Sahin 2022-06-22 12:34:52 +03:00
parent a886e93c7e
commit 8854b81977
1 changed files with 22 additions and 4 deletions

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.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
import im.vector.app.features.poll.PollState import im.vector.app.features.poll.PollState
@ -38,12 +39,17 @@ private val A_MESSAGE_INFORMATION_DATA = MessageInformationData(
senderId = "senderId", senderId = "senderId",
ageLocalTS = 0, ageLocalTS = 0,
avatarUrl = "", avatarUrl = "",
sendState = SendState.SENDING, sendState = SendState.SENT,
messageLayout = TimelineMessageLayout.Default(showAvatar = true, showDisplayName = true, showTimestamp = true), messageLayout = TimelineMessageLayout.Default(showAvatar = true, showDisplayName = true, showTimestamp = true),
reactionsSummary = ReactionsSummaryData(), reactionsSummary = ReactionsSummaryData(),
sentByMe = true, sentByMe = true,
) )
private val A_POLL_RESPONSE_DATA = PollResponseData(
myVote = null,
votes = emptyMap(),
)
class PollItemFactoryTest { class PollItemFactoryTest {
private val testDispatcher = UnconfinedTestDispatcher() private val testDispatcher = UnconfinedTestDispatcher()
@ -72,11 +78,23 @@ class PollItemFactoryTest {
} }
@Test @Test
fun `given a sending poll state then returns PollState as Sending`() = runTest { fun `given a sending poll state then PollState is Sending`() = runTest {
val sendingPollInformationData = A_MESSAGE_INFORMATION_DATA.copy(sendState = SendState.SENT)
pollItemFactory.createPollState( pollItemFactory.createPollState(
informationData = A_MESSAGE_INFORMATION_DATA, informationData = sendingPollInformationData,
pollResponseSummary = null, pollResponseSummary = A_POLL_RESPONSE_DATA,
pollContent = MessagePollContent() pollContent = MessagePollContent()
) shouldBe PollState.Sending ) shouldBe PollState.Sending
} }
@Test
fun `given a sent poll state when poll is closed then PollState is Ended`() = runTest {
val closedPollSummary = A_POLL_RESPONSE_DATA.copy(isClosed = true)
pollItemFactory.createPollState(
informationData = A_MESSAGE_INFORMATION_DATA,
pollResponseSummary = closedPollSummary,
pollContent = MessagePollContent()
) shouldBe PollState.Ended
}
} }