mirror of
https://github.com/element-hq/element-android
synced 2024-11-26 19:35:42 +03:00
Adding unit test
This commit is contained in:
parent
454ce1c095
commit
6034085244
1 changed files with 16 additions and 2 deletions
|
@ -147,6 +147,19 @@ class DefaultPollAggregationProcessorTest {
|
|||
pollAggregationProcessor.handlePollResponseEvent(session, realm.instance, AN_INVALID_POLL_RESPONSE_EVENT).shouldBeFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `given a poll response event and no existing poll start event, when processing, then is processed and returns true`() {
|
||||
// Given
|
||||
mockRoom(roomId = A_ROOM_ID, eventId = AN_EVENT_ID, hasExistingTimelineEvent = false)
|
||||
every { realm.instance.createObject(PollResponseAggregatedSummaryEntity::class.java) } returns PollResponseAggregatedSummaryEntity()
|
||||
|
||||
// When
|
||||
val result = pollAggregationProcessor.handlePollResponseEvent(session, realm.instance, A_POLL_RESPONSE_EVENT)
|
||||
|
||||
// Then
|
||||
result.shouldBeTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `given a poll end event, when processing, then is processed and return true`() = runTest {
|
||||
// Given
|
||||
|
@ -234,11 +247,12 @@ class DefaultPollAggregationProcessorTest {
|
|||
|
||||
private fun mockRoom(
|
||||
roomId: String,
|
||||
eventId: String
|
||||
eventId: String,
|
||||
hasExistingTimelineEvent: Boolean = true,
|
||||
) {
|
||||
val room = mockk<Room>()
|
||||
every { session.getRoom(roomId) } returns room
|
||||
every { room.getTimelineEvent(eventId) } returns A_TIMELINE_EVENT
|
||||
every { room.getTimelineEvent(eventId) } returns if (hasExistingTimelineEvent) A_TIMELINE_EVENT else null
|
||||
}
|
||||
|
||||
private fun mockRedactionPowerLevels(userId: String, isAbleToRedact: Boolean): PowerLevelsHelper {
|
||||
|
|
Loading…
Reference in a new issue