mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 11:59:12 +03:00
Fixing unit tests
This commit is contained in:
parent
6c0b7f7b43
commit
3e05431e6f
3 changed files with 14 additions and 8 deletions
|
@ -27,6 +27,7 @@ import kotlinx.coroutines.test.runTest
|
|||
import org.amshove.kluent.shouldBeEqualTo
|
||||
import org.junit.After
|
||||
import org.junit.Test
|
||||
import org.matrix.android.sdk.api.session.room.location.UpdateLiveLocationShareResult
|
||||
import org.matrix.android.sdk.api.session.room.model.livelocation.LiveLocationShareAggregatedSummary
|
||||
import org.matrix.android.sdk.api.util.Cancelable
|
||||
import org.matrix.android.sdk.internal.database.mapper.LiveLocationShareAggregatedSummaryMapper
|
||||
|
@ -119,11 +120,11 @@ internal class DefaultLocationSharingServiceTest {
|
|||
|
||||
@Test
|
||||
fun `live location share can be started with a given timeout`() = runTest {
|
||||
coEvery { startLiveLocationShareTask.execute(any()) } returns AN_EVENT_ID
|
||||
coEvery { startLiveLocationShareTask.execute(any()) } returns UpdateLiveLocationShareResult.Success(AN_EVENT_ID)
|
||||
|
||||
val eventId = defaultLocationSharingService.startLiveLocationShare(A_TIMEOUT)
|
||||
val result = defaultLocationSharingService.startLiveLocationShare(A_TIMEOUT)
|
||||
|
||||
eventId shouldBeEqualTo AN_EVENT_ID
|
||||
result shouldBeEqualTo UpdateLiveLocationShareResult.Success(AN_EVENT_ID)
|
||||
val expectedParams = StartLiveLocationShareTask.Params(
|
||||
roomId = A_ROOM_ID,
|
||||
timeoutMillis = A_TIMEOUT
|
||||
|
@ -133,10 +134,11 @@ internal class DefaultLocationSharingServiceTest {
|
|||
|
||||
@Test
|
||||
fun `live location share can be stopped`() = runTest {
|
||||
coEvery { stopLiveLocationShareTask.execute(any()) } just runs
|
||||
coEvery { stopLiveLocationShareTask.execute(any()) } returns UpdateLiveLocationShareResult.Success(AN_EVENT_ID)
|
||||
|
||||
defaultLocationSharingService.stopLiveLocationShare()
|
||||
val result = defaultLocationSharingService.stopLiveLocationShare()
|
||||
|
||||
result shouldBeEqualTo UpdateLiveLocationShareResult.Success(AN_EVENT_ID)
|
||||
val expectedParams = StopLiveLocationShareTask.Params(
|
||||
roomId = A_ROOM_ID
|
||||
)
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.junit.After
|
|||
import org.junit.Test
|
||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||
import org.matrix.android.sdk.api.session.events.model.toContent
|
||||
import org.matrix.android.sdk.api.session.room.location.UpdateLiveLocationShareResult
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageBeaconInfoContent
|
||||
import org.matrix.android.sdk.internal.session.room.state.SendStateTask
|
||||
import org.matrix.android.sdk.test.fakes.FakeClock
|
||||
|
@ -53,7 +54,7 @@ internal class DefaultStartLiveLocationShareTaskTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `given parameters when calling the task then it is correctly executed`() = runTest {
|
||||
fun `given parameters an no error when calling the task then it is correctly executed`() = runTest {
|
||||
val params = StartLiveLocationShareTask.Params(
|
||||
roomId = A_ROOM_ID,
|
||||
timeoutMillis = A_TIMEOUT
|
||||
|
@ -63,7 +64,7 @@ internal class DefaultStartLiveLocationShareTaskTest {
|
|||
|
||||
val result = defaultStartLiveLocationShareTask.execute(params)
|
||||
|
||||
result shouldBeEqualTo AN_EVENT_ID
|
||||
result shouldBeEqualTo UpdateLiveLocationShareResult.Success(AN_EVENT_ID)
|
||||
val expectedBeaconContent = MessageBeaconInfoContent(
|
||||
timeout = params.timeoutMillis,
|
||||
isLive = true,
|
||||
|
|
|
@ -19,11 +19,13 @@ package org.matrix.android.sdk.internal.session.room.location
|
|||
import io.mockk.unmockkAll
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.amshove.kluent.shouldBeEqualTo
|
||||
import org.junit.After
|
||||
import org.junit.Test
|
||||
import org.matrix.android.sdk.api.session.events.model.Event
|
||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||
import org.matrix.android.sdk.api.session.events.model.toContent
|
||||
import org.matrix.android.sdk.api.session.room.location.UpdateLiveLocationShareResult
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageBeaconInfoContent
|
||||
import org.matrix.android.sdk.internal.session.room.state.SendStateTask
|
||||
import org.matrix.android.sdk.test.fakes.FakeSendStateTask
|
||||
|
@ -66,8 +68,9 @@ class DefaultStopLiveLocationShareTaskTest {
|
|||
fakeStateEventDataSource.givenGetStateEventReturns(currentStateEvent)
|
||||
fakeSendStateTask.givenExecuteRetryReturns(AN_EVENT_ID)
|
||||
|
||||
defaultStopLiveLocationShareTask.execute(params)
|
||||
val result = defaultStopLiveLocationShareTask.execute(params)
|
||||
|
||||
result shouldBeEqualTo UpdateLiveLocationShareResult.Success(AN_EVENT_ID)
|
||||
val expectedBeaconContent = MessageBeaconInfoContent(
|
||||
timeout = A_TIMEOUT,
|
||||
isLive = false,
|
||||
|
|
Loading…
Reference in a new issue