package cy.hexor.furumi.domain.model

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

class ServerConfigTest {
    @Test
    fun normalizeBaseUrl_addsHttpsWhenSchemeIsMissing() {
        val result = ServerConfig.normalizeBaseUrl("media.example.com")

        assertEquals("https://media.example.com", result.getOrThrow())
    }

    @Test
    fun normalizeBaseUrl_trimsTrailingSlashButKeepsPath() {
        val result = ServerConfig.normalizeBaseUrl(" https://media.example.com/furumi/ ")

        assertEquals("https://media.example.com/furumi", result.getOrThrow())
    }

    @Test
    fun normalizeBaseUrl_rejectsQueryStrings() {
        val result = ServerConfig.normalizeBaseUrl("https://media.example.com?token=bad")

        assertTrue(result.isFailure)
    }

    @Test
    fun credentials_requireLogin() {
        val result = ServerConfig.credentials("https://media.example.com", " ")

        assertTrue(result.isFailure)
    }
}
