With robotelectric, how can I use Uri.js parse? js...
# android
r
With robotelectric, how can I use Uri.js parse? json I'm getting bullied
Method parse in android.net.Uri not mocked.
, even though I added
@RunWith(RobolectricTestRunner::class)
on top of my class.
not kotlin but kotlin colored 4
Code:
Copy code
import android.net.Uri
import io.kotest.matchers.shouldBe
import org.junit.jupiter.api.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config

@RunWith(RobolectricTestRunner::class)
@Config(sdk = [33])
class YoutubePlayerKtTest {

    val youtubeShortURL = Uri.parse("<https://youtu.be/l6rS8Dv5g-8>")
    val youtubeLongURL = Uri.parse("<https://www.youtube.com/watch?v=l6rS8Dv5g-8>")
    val youtubePlaylistURL = Uri.parse("<https://www.youtube.com/watch?v=BE2Fj0W4jP4&list=PLmWYEDTNOGUIDlp5epnDhPH-zPI0KfTQG>")

    @Test
    fun testShort() {
        parseYoutubeURL(youtubeShortURL) shouldBe CardMessage.YoutubeVideo("l6rS8Dv5g-8")
    }

    @Test
    fun testLong() {
        parseYoutubeURL(youtubeLongURL) shouldBe CardMessage.YoutubeVideo("l6rS8Dv5g-8")
    }

    @Test
    fun testPlaylist() {
        parseYoutubeURL(youtubePlaylistURL) shouldBe CardMessage.YoutubePlaylist("PLmWYEDTNOGUIDlp5epnDhPH-zPI0KfTQG")
    }
}
a
getting bullied 🤣