package com.ponzischeme89.memby.data

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

class ServerConfigTest {
    @Test
    fun `hardwired address wins over anything the user typed`() {
        assertEquals(
            "http://tv.example.com:8096",
            resolveServerUrl("http://tv.example.com:8096/", "http://192.168.1.50:8096"),
        )
    }

    @Test
    fun `hardwired address is normalised like a typed one`() {
        assertEquals("http://10.0.0.5:8096", resolveServerUrl("10.0.0.5:8096", ""))
    }

    @Test
    fun `falls back to the typed address when the build pins nothing`() {
        assertEquals("https://emby.example.com", resolveServerUrl(null, "https://emby.example.com/"))
        assertEquals("https://emby.example.com", resolveServerUrl("  ", "https://emby.example.com/"))
    }

    @Test
    fun `returns null when neither source supplies an address`() {
        assertNull(resolveServerUrl(null, ""))
    }
}
