mirror of
https://github.com/element-hq/element-android
synced 2024-11-23 09:55:40 +03:00
Use private method to mockk voice broadcast event
This commit is contained in:
parent
2df94807e0
commit
493fa7a0eb
1 changed files with 18 additions and 32 deletions
|
@ -53,25 +53,10 @@ internal class GetVoiceBroadcastStateEventUseCaseTest {
|
|||
fun `given there are several related events related to the given vb, when execute, then return the most recent one`() {
|
||||
// Given
|
||||
val aVoiceBroadcast = VoiceBroadcast(A_VOICE_BROADCAST_ID, A_ROOM_ID)
|
||||
val aListOfTimelineEvents = listOf<TimelineEvent>(
|
||||
mockk(relaxed = true) {
|
||||
every { root.eventId } returns "event_id_1"
|
||||
every { root.type } returns VoiceBroadcastConstants.STATE_ROOM_VOICE_BROADCAST_INFO
|
||||
every { root.isRedacted() } returns false
|
||||
every { root.originServerTs } returns 1L
|
||||
},
|
||||
mockk(relaxed = true) {
|
||||
every { root.eventId } returns "event_id_3"
|
||||
every { root.type } returns VoiceBroadcastConstants.STATE_ROOM_VOICE_BROADCAST_INFO
|
||||
every { root.isRedacted() } returns false
|
||||
every { root.originServerTs } returns 3L
|
||||
},
|
||||
mockk(relaxed = true) {
|
||||
every { root.eventId } returns "event_id_2"
|
||||
every { root.type } returns VoiceBroadcastConstants.STATE_ROOM_VOICE_BROADCAST_INFO
|
||||
every { root.isRedacted() } returns false
|
||||
every { root.originServerTs } returns 2L
|
||||
},
|
||||
val aListOfTimelineEvents = listOf(
|
||||
givenAVoiceBroadcastEvent(eventId = "event_id_1", isRedacted = false, timestamp = 1L),
|
||||
givenAVoiceBroadcastEvent(eventId = "event_id_3", isRedacted = false, timestamp = 3L),
|
||||
givenAVoiceBroadcastEvent(eventId = "event_id_2", isRedacted = false, timestamp = 2L),
|
||||
)
|
||||
every { fakeSession.getRoom(A_ROOM_ID)?.timelineService()?.getTimelineEventsRelatedTo(any(), any()) } returns aListOfTimelineEvents
|
||||
|
||||
|
@ -87,19 +72,9 @@ internal class GetVoiceBroadcastStateEventUseCaseTest {
|
|||
fun `given there are several related events related to the given vb, when execute, then return the most recent one which is not redacted`() {
|
||||
// Given
|
||||
val aVoiceBroadcast = VoiceBroadcast(A_VOICE_BROADCAST_ID, A_ROOM_ID)
|
||||
val aListOfTimelineEvents = listOf<TimelineEvent>(
|
||||
mockk(relaxed = true) {
|
||||
every { root.eventId } returns "event_id_1"
|
||||
every { root.type } returns VoiceBroadcastConstants.STATE_ROOM_VOICE_BROADCAST_INFO
|
||||
every { root.isRedacted() } returns false
|
||||
every { root.originServerTs } returns 1L
|
||||
},
|
||||
mockk(relaxed = true) {
|
||||
every { root.eventId } returns "event_id_2"
|
||||
every { root.type } returns VoiceBroadcastConstants.STATE_ROOM_VOICE_BROADCAST_INFO
|
||||
every { root.isRedacted() } returns true
|
||||
every { root.originServerTs } returns 2L
|
||||
},
|
||||
val aListOfTimelineEvents = listOf(
|
||||
givenAVoiceBroadcastEvent(eventId = "event_id_1", isRedacted = false, timestamp = 1L),
|
||||
givenAVoiceBroadcastEvent(eventId = "event_id_2", isRedacted = true, timestamp = 2L),
|
||||
)
|
||||
every { fakeSession.getRoom(A_ROOM_ID)?.timelineService()?.getTimelineEventsRelatedTo(any(), any()) } returns aListOfTimelineEvents
|
||||
|
||||
|
@ -110,4 +85,15 @@ internal class GetVoiceBroadcastStateEventUseCaseTest {
|
|||
result.shouldNotBeNull()
|
||||
result.root.eventId shouldBeEqualTo "event_id_1"
|
||||
}
|
||||
|
||||
private fun givenAVoiceBroadcastEvent(
|
||||
eventId: String,
|
||||
isRedacted: Boolean,
|
||||
timestamp: Long,
|
||||
) = mockk<TimelineEvent>(relaxed = true) {
|
||||
every { root.eventId } returns eventId
|
||||
every { root.type } returns VoiceBroadcastConstants.STATE_ROOM_VOICE_BROADCAST_INFO
|
||||
every { root.isRedacted() } returns isRedacted
|
||||
every { root.originServerTs } returns timestamp
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue