From 6f4e079a2e175d0e1f85b9bb19aac96a06beaf3d Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Mon, 27 Jun 2022 14:07:26 +0300 Subject: [PATCH] Fix undisclosed poll unit test. --- .../factory/PollItemViewStateFactoryTest.kt | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/vector/src/test/java/im/vector/app/features/home/room/detail/timeline/factory/PollItemViewStateFactoryTest.kt b/vector/src/test/java/im/vector/app/features/home/room/detail/timeline/factory/PollItemViewStateFactoryTest.kt index fa36ddb71e..a1c332c029 100644 --- a/vector/src/test/java/im/vector/app/features/home/room/detail/timeline/factory/PollItemViewStateFactoryTest.kt +++ b/vector/src/test/java/im/vector/app/features/home/room/detail/timeline/factory/PollItemViewStateFactoryTest.kt @@ -145,16 +145,28 @@ class PollItemViewStateFactoryTest { ) } - /* @Test - fun `given a sent poll when undisclosed poll type is selected then PollState is Undisclosed`() = runTest { - pollItemViewStateFactory.createPollState( - informationData = A_MESSAGE_INFORMATION_DATA, - pollResponseSummary = A_POLL_RESPONSE_DATA, + fun `given a sent poll when undisclosed poll type is selected then poll is votable and option states are PollUndisclosed`() = runTest { + val pollViewState = pollItemViewStateFactory.create( pollContent = A_POLL_CONTENT, - ) shouldBe PollState.Undisclosed + informationData = A_MESSAGE_INFORMATION_DATA, + ) + + pollViewState shouldBeEqualTo PollViewState( + question = A_POLL_CONTENT.getBestPollCreationInfo()?.question?.getBestQuestion() ?: "", + totalVotes = "", + canVote = true, + optionViewStates = A_POLL_CONTENT.getBestPollCreationInfo()?.answers?.map { answer -> + PollOptionViewState.PollUndisclosed( + optionId = answer.id ?: "", + optionAnswer = answer.getBestAnswer() ?: "", + isSelected = false + ) + }, + ) } + /* @Test fun `given a sent poll when my vote exists then PollState is Voted`() = runTest { val votedPollData = A_POLL_RESPONSE_DATA.copy(