Adding unit test
This commit is contained in:
parent
454ce1c095
commit
6034085244
|
@ -147,6 +147,19 @@ class DefaultPollAggregationProcessorTest {
|
||||||
pollAggregationProcessor.handlePollResponseEvent(session, realm.instance, AN_INVALID_POLL_RESPONSE_EVENT).shouldBeFalse()
|
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
|
@Test
|
||||||
fun `given a poll end event, when processing, then is processed and return true`() = runTest {
|
fun `given a poll end event, when processing, then is processed and return true`() = runTest {
|
||||||
// Given
|
// Given
|
||||||
|
@ -234,11 +247,12 @@ class DefaultPollAggregationProcessorTest {
|
||||||
|
|
||||||
private fun mockRoom(
|
private fun mockRoom(
|
||||||
roomId: String,
|
roomId: String,
|
||||||
eventId: String
|
eventId: String,
|
||||||
|
hasExistingTimelineEvent: Boolean = true,
|
||||||
) {
|
) {
|
||||||
val room = mockk<Room>()
|
val room = mockk<Room>()
|
||||||
every { session.getRoom(roomId) } returns 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 {
|
private fun mockRedactionPowerLevels(userId: String, isAbleToRedact: Boolean): PowerLevelsHelper {
|
||||||
|
|
Loading…
Reference in New Issue