Re-organize String extensions to correct packages and update test name (#219)

This commit is contained in:
Andrew Haisting 2023-11-07 11:53:26 -06:00 committed by Álison Fernandes
parent aeb5ff3734
commit c9b379af99
5 changed files with 9 additions and 10 deletions

View file

@ -1,7 +1,5 @@
package com.x8bit.bitwarden.data.platform.util
import androidx.compose.ui.text.AnnotatedString
/**
* Returns the original [String] only if:
*
@ -12,8 +10,3 @@ import androidx.compose.ui.text.AnnotatedString
*/
fun String?.orNullIfBlank(): String? =
this?.takeUnless { it.isBlank() }
/**
* Returns the [String] as an [AnnotatedString].
*/
fun String.toAnnotatedString(): AnnotatedString = AnnotatedString(text = this)

View file

@ -1,5 +1,6 @@
package com.x8bit.bitwarden.ui.platform.base.util
import androidx.compose.ui.text.AnnotatedString
import java.net.URI
/**
@ -21,3 +22,8 @@ fun String.isValidUri(): Boolean =
} catch (_: IllegalArgumentException) {
false
}
/**
* Returns the [String] as an [AnnotatedString].
*/
fun String.toAnnotatedString(): AnnotatedString = AnnotatedString(text = this)

View file

@ -43,11 +43,11 @@ import androidx.core.net.toUri
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.data.platform.util.toAnnotatedString
import com.x8bit.bitwarden.ui.platform.base.util.EventsEffect
import com.x8bit.bitwarden.ui.platform.base.util.IntentHandler
import com.x8bit.bitwarden.ui.platform.base.util.Text
import com.x8bit.bitwarden.ui.platform.base.util.asText
import com.x8bit.bitwarden.ui.platform.base.util.toAnnotatedString
import com.x8bit.bitwarden.ui.platform.components.BitwardenExternalLinkRow
import com.x8bit.bitwarden.ui.platform.components.BitwardenTopAppBar
import com.x8bit.bitwarden.ui.platform.components.BitwardenWideSwitch

View file

@ -4,7 +4,7 @@ import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
class StringExtensionTest {
class StringExtensionsTest {
@Test
fun `emails without an @ character should be invalid`() {

View file

@ -8,10 +8,10 @@ import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.core.net.toUri
import com.x8bit.bitwarden.data.platform.util.toAnnotatedString
import com.x8bit.bitwarden.ui.platform.base.BaseComposeTest
import com.x8bit.bitwarden.ui.platform.base.util.IntentHandler
import com.x8bit.bitwarden.ui.platform.base.util.asText
import com.x8bit.bitwarden.ui.platform.base.util.toAnnotatedString
import io.mockk.Runs
import io.mockk.every
import io.mockk.just