package com.github.nullptroma.wallenc.ui.navigation

import android.content.Intent
import android.net.Uri
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config

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

    @Test
    fun matchesWallencViewIntent() {
        val intent = Intent(Intent.ACTION_VIEW, Uri.parse(WallencDeepLinks.MAIN_URI_PATTERN))
        assertTrue(intent.matchesWallencDeepLink())
    }

    @Test
    fun rejectsUnrelatedIntent() {
        val intent = Intent(Intent.ACTION_MAIN)
        assertFalse(intent.matchesWallencDeepLink())
    }

    @Test
    fun matchesTasksAndSettingsHosts() {
        assertTrue(
            Intent(Intent.ACTION_VIEW, Uri.parse(WallencDeepLinks.TASKS_URI_PATTERN))
                .matchesWallencDeepLink(),
        )
        assertTrue(
            Intent(Intent.ACTION_VIEW, Uri.parse(WallencDeepLinks.SETTINGS_URI_PATTERN))
                .matchesWallencDeepLink(),
        )
    }
}
