package com.hermes.app.core.localization

import androidx.test.core.app.ApplicationProvider
import com.hermes.app.R
import kotlin.test.Test
import kotlin.test.assertEquals
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
import org.junit.runner.RunWith

@RunWith(RobolectricTestRunner::class)
@Config(sdk = [34])
class HermesLocalizationStoreTest {
    private val context = ApplicationProvider.getApplicationContext<android.content.Context>()
    private val store = HermesLocalizationStore(context)

    @Test
    fun englishStringsLoad() {
        assertEquals("Settings", store.string("en", R.string.settings_title))
        assertEquals("Enabled", store.string("en", R.string.settings_enabled))
    }

    @Test
    fun swedishStringsLoad() {
        assertEquals("Inställningar", store.string("sv", R.string.settings_title))
        assertEquals("Aktiverad", store.string("sv", R.string.settings_enabled))
    }

    @Test
    fun unsupportedLocaleFallsBackToEnglish() {
        store.setLocale("fr")

        assertEquals("en", store.localeCode.value)
        assertEquals("English", store.localeName("en", "fr"))
    }
}
