mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-25 10:55:55 +03:00
Fix test compilation
This commit is contained in:
parent
128d3845b9
commit
f64db7f5f3
1 changed files with 25 additions and 1 deletions
|
@ -26,6 +26,8 @@ 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.model.message.MessageTextContent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageType
|
||||
import org.matrix.android.sdk.api.session.room.sender.SenderInfo
|
||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
internal class UrlsExtractorTest : InstrumentedTest {
|
||||
|
@ -36,6 +38,7 @@ internal class UrlsExtractorTest : InstrumentedTest {
|
|||
fun wrongEventTypeTest() {
|
||||
createEvent(body = "https://matrix.org")
|
||||
.copy(type = EventType.STATE_ROOM_GUEST_ACCESS)
|
||||
.toFakeTimelineEvent()
|
||||
.let { urlsExtractor.extract(it) }
|
||||
.size shouldBeEqualTo 0
|
||||
}
|
||||
|
@ -43,6 +46,7 @@ internal class UrlsExtractorTest : InstrumentedTest {
|
|||
@Test
|
||||
fun oneUrlTest() {
|
||||
createEvent(body = "https://matrix.org")
|
||||
.toFakeTimelineEvent()
|
||||
.let { urlsExtractor.extract(it) }
|
||||
.let { result ->
|
||||
result.size shouldBeEqualTo 1
|
||||
|
@ -53,6 +57,7 @@ internal class UrlsExtractorTest : InstrumentedTest {
|
|||
@Test
|
||||
fun withoutProtocolTest() {
|
||||
createEvent(body = "www.matrix.org")
|
||||
.toFakeTimelineEvent()
|
||||
.let { urlsExtractor.extract(it) }
|
||||
.size shouldBeEqualTo 0
|
||||
}
|
||||
|
@ -60,6 +65,7 @@ internal class UrlsExtractorTest : InstrumentedTest {
|
|||
@Test
|
||||
fun oneUrlWithParamTest() {
|
||||
createEvent(body = "https://matrix.org?foo=bar")
|
||||
.toFakeTimelineEvent()
|
||||
.let { urlsExtractor.extract(it) }
|
||||
.let { result ->
|
||||
result.size shouldBeEqualTo 1
|
||||
|
@ -70,6 +76,7 @@ internal class UrlsExtractorTest : InstrumentedTest {
|
|||
@Test
|
||||
fun oneUrlWithParamsTest() {
|
||||
createEvent(body = "https://matrix.org?foo=bar&bar=foo")
|
||||
.toFakeTimelineEvent()
|
||||
.let { urlsExtractor.extract(it) }
|
||||
.let { result ->
|
||||
result.size shouldBeEqualTo 1
|
||||
|
@ -80,16 +87,18 @@ internal class UrlsExtractorTest : InstrumentedTest {
|
|||
@Test
|
||||
fun oneUrlInlinedTest() {
|
||||
createEvent(body = "Hello https://matrix.org, how are you?")
|
||||
.toFakeTimelineEvent()
|
||||
.let { urlsExtractor.extract(it) }
|
||||
.let { result ->
|
||||
result.size shouldBeEqualTo 1
|
||||
result[0] shouldBeEqualTo "https://matrix.org"
|
||||
result[0] shouldBeEqualTo "https://matrix.org"
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun twoUrlsTest() {
|
||||
createEvent(body = "https://matrix.org https://example.org")
|
||||
.toFakeTimelineEvent()
|
||||
.let { urlsExtractor.extract(it) }
|
||||
.let { result ->
|
||||
result.size shouldBeEqualTo 2
|
||||
|
@ -105,4 +114,19 @@ internal class UrlsExtractorTest : InstrumentedTest {
|
|||
body = body
|
||||
).toContent()
|
||||
)
|
||||
|
||||
private fun Event.toFakeTimelineEvent(): TimelineEvent {
|
||||
return TimelineEvent(
|
||||
root = this,
|
||||
localId = 0L,
|
||||
eventId = "",
|
||||
displayIndex = 0,
|
||||
senderInfo = SenderInfo(
|
||||
userId = "",
|
||||
displayName = null,
|
||||
isUniqueDisplayName = true,
|
||||
avatarUrl = null
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue