mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-15 01:35:07 +08:00
Improving send locations tasks tests
This commit is contained in:
parent
8d2a914c64
commit
8860dac759
@ -16,11 +16,14 @@
|
||||
|
||||
package org.matrix.android.sdk.internal.session.room.location
|
||||
|
||||
import io.mockk.mockk
|
||||
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.util.Cancelable
|
||||
import org.matrix.android.sdk.test.fakes.FakeEventSenderProcessor
|
||||
import org.matrix.android.sdk.test.fakes.FakeLocalEchoEventFactory
|
||||
|
||||
@ -55,13 +58,15 @@ internal class DefaultSendLiveLocationTaskTest {
|
||||
longitude = A_LONGITUDE,
|
||||
uncertainty = AN_UNCERTAINTY
|
||||
)
|
||||
|
||||
val event = fakeLocalEchoEventFactory.givenCreateLiveLocationEvent(
|
||||
withLocalEcho = true
|
||||
)
|
||||
val cancelable = mockk<Cancelable>()
|
||||
fakeEventSenderProcessor.givenPostEventReturns(event, cancelable)
|
||||
|
||||
defaultSendLiveLocationTask.execute(params)
|
||||
val result = defaultSendLiveLocationTask.execute(params)
|
||||
|
||||
result shouldBeEqualTo cancelable
|
||||
fakeLocalEchoEventFactory.verifyCreateLiveLocationEvent(
|
||||
roomId = params.roomId,
|
||||
beaconInfoEventId = params.beaconInfoEventId,
|
||||
|
@ -16,11 +16,14 @@
|
||||
|
||||
package org.matrix.android.sdk.internal.session.room.location
|
||||
|
||||
import io.mockk.mockk
|
||||
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.util.Cancelable
|
||||
import org.matrix.android.sdk.test.fakes.FakeEventSenderProcessor
|
||||
import org.matrix.android.sdk.test.fakes.FakeLocalEchoEventFactory
|
||||
|
||||
@ -54,13 +57,15 @@ internal class DefaultSendStaticLocationTaskTest {
|
||||
uncertainty = AN_UNCERTAINTY,
|
||||
isUserLocation = true
|
||||
)
|
||||
|
||||
val event = fakeLocalEchoEventFactory.givenCreateStaticLocationEvent(
|
||||
withLocalEcho = true
|
||||
)
|
||||
val cancelable = mockk<Cancelable>()
|
||||
fakeEventSenderProcessor.givenPostEventReturns(event, cancelable)
|
||||
|
||||
defaultSendStaticLocationTask.execute(params)
|
||||
val result = defaultSendStaticLocationTask.execute(params)
|
||||
|
||||
result shouldBeEqualTo cancelable
|
||||
fakeLocalEchoEventFactory.verifyCreateStaticLocationEvent(
|
||||
roomId = params.roomId,
|
||||
latitude = params.latitude,
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
package org.matrix.android.sdk.test.fakes
|
||||
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import org.matrix.android.sdk.api.session.events.model.Event
|
||||
import org.matrix.android.sdk.api.util.Cancelable
|
||||
@ -23,5 +24,7 @@ import org.matrix.android.sdk.internal.session.room.send.queue.EventSenderProces
|
||||
|
||||
internal class FakeEventSenderProcessor : EventSenderProcessor by mockk() {
|
||||
|
||||
override fun postEvent(event: Event): Cancelable = mockk()
|
||||
fun givenPostEventReturns(event: Event, cancelable: Cancelable) {
|
||||
every { postEvent(event) } returns cancelable
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user