package ch.dissem.yaep.ui.common

import androidx.compose.ui.test.ExperimentalTestApi
import androidx.compose.ui.test.runComposeUiTest
import ch.dissem.yaep.domain.Animal
import ch.dissem.yaep.domain.Drink
import ch.dissem.yaep.domain.Fruit
import ch.dissem.yaep.domain.ItemClass
import ch.dissem.yaep.domain.Nationality
import ch.dissem.yaep.domain.Profession
import ch.dissem.yaep.domain.Transportation
import ch.tutteli.atrium.api.fluent.en_GB.notToBeBlank
import ch.tutteli.atrium.api.fluent.en_GB.toHaveElementsAndAll
import ch.tutteli.atrium.api.verbs.expect
import org.jetbrains.compose.resources.stringResource
import kotlin.test.Test

@OptIn(ExperimentalTestApi::class)
class NamesTest {
    @Test
    fun ensure_names_are_defined_for_animal() {
        ensure_names_are_defined_for(Animal.items)
    }

    @Test
    fun ensure_names_are_defined_for_nationality() {
        ensure_names_are_defined_for(Nationality.items)
    }

    @Test
    fun ensure_names_are_defined_for_drink() {
        ensure_names_are_defined_for(Drink.items)
    }

    @Test
    fun ensure_names_are_defined_for_profession() {
        ensure_names_are_defined_for(Profession.items)
    }

    @Test
    fun ensure_names_are_defined_for_fruit() {
        ensure_names_are_defined_for(Fruit.items)
    }

    @Test
    fun ensure_names_are_defined_for_dessert() {
        ensure_names_are_defined_for(Fruit.items)
    }

    @Test
    fun ensure_names_are_defined_for_transportation() {
        ensure_names_are_defined_for(Transportation.items)
    }

    fun ensure_names_are_defined_for(items: List<ItemClass<*>>) {
        runComposeUiTest {
            var strings = listOf<String>()
            setContent {
                strings = items.map { stringResource(it.localName) }
            }
            expect(strings).toHaveElementsAndAll {
                notToBeBlank()
            }
        }
    }
}