Ensure test does not fail.

This commit is contained in:
Benoit Marty 2023-12-15 17:58:19 +01:00 committed by Benoit Marty
parent 1b0a4093d9
commit 5d4eaae933

View file

@ -242,8 +242,10 @@ class TimelineItemContentMessageFactory @Inject constructor(
}
}
@Suppress("USELESS_ELVIS")
private fun String.withLinks(): CharSequence? {
val spannable = toSpannable()
/* Note: toSpannable() can return null when running unit tests */
val spannable = toSpannable() ?: return null
val addedLinks = LinkifyCompat.addLinks(spannable, Linkify.WEB_URLS or Linkify.PHONE_NUMBERS or Linkify.EMAIL_ADDRESSES)
return spannable.takeIf { addedLinks }
}