package com.ponzischeme89.memby.data

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

class ProfileSettingsTest {
    private val profile = EmbyProfile(
        id = "server::user",
        serverUrl = "http://emby",
        token = "token",
        userId = "user",
        username = "Matt",
    )

    @Test
    fun `active profile matches both server and user`() {
        val settings = Settings(
            serverUrl = profile.serverUrl,
            token = profile.token,
            userId = profile.userId,
            profiles = listOf(profile),
        )

        assertEquals(profile.id, settings.activeProfileId)
    }

    @Test
    fun `profile from another server is not treated as active`() {
        val settings = Settings(
            serverUrl = "http://another-server",
            token = profile.token,
            userId = profile.userId,
            profiles = listOf(profile),
        )

        assertNull(settings.activeProfileId)
    }

    @Test
    fun `for you choices belong to each profile`() {
        val matt = profile.copy(forYouMinutes = 60, hasOpenedForYou = true)
        val family = profile.copy(
            id = "server::family",
            userId = "family",
            username = "FamilyTV",
            forYouMinutes = 30,
            hasOpenedForYou = false,
        )

        assertEquals(60, matt.forYouMinutes)
        assertEquals(true, matt.hasOpenedForYou)
        assertEquals(30, family.forYouMinutes)
        assertEquals(false, family.hasOpenedForYou)
    }

    @Test
    fun `welcome quote style belongs to each profile`() {
        val matt = profile.copy(welcomeQuoteStyle = "homicidal")
        val family = profile.copy(
            id = "server::family",
            userId = "family",
            welcomeQuoteStyle = "positive",
        )

        assertEquals("homicidal", matt.welcomeQuoteStyle)
        assertEquals("positive", family.welcomeQuoteStyle)
    }
}
