package com.aletheia.app.data

import org.junit.Assert.assertEquals
import org.junit.Test

class SettingsRepositoryTest {
    @Test
    fun usesFlibustaForEmptyAndLegacyQBooksAddresses() {
        assertEquals(SettingsRepository.DEFAULT_CATALOG_URL, SettingsRepository.resolveCatalogUrl(null))
        assertEquals(SettingsRepository.DEFAULT_CATALOG_URL, SettingsRepository.resolveCatalogUrl(""))
        assertEquals(
            SettingsRepository.DEFAULT_CATALOG_URL,
            SettingsRepository.resolveCatalogUrl("https://qbooks.kusoft.xyz/")
        )
        assertEquals(
            SettingsRepository.DEFAULT_CATALOG_URL,
            SettingsRepository.resolveCatalogUrl("https://m.flibusta.is/opds/")
        )
    }

    @Test
    fun preservesCustomCatalogAddress() {
        assertEquals(
            "https://books.example/opds",
            SettingsRepository.resolveCatalogUrl("  https://books.example/opds/ ")
        )
    }
}
