package com.example.libary

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
import androidx.compose.ui.unit.dp
import org.junit.Assert
import org.junit.Rule
import org.junit.Test

class TabbarTest {

    @get:Rule
    val composeRule = createComposeRule()

    @Test
    fun test() {

        var valueName = ""

        composeRule.setContent {
            val value = remember { mutableStateOf(defaultTabBarData[0]) }

            LaunchedEffect(value.value) {
                valueName = value.value.name
            }

            Column {
                Spacer(Modifier.height(100.dp))
                TabBar(
                    value = value
                )
            }
        }

        composeRule.onNodeWithTag("Главная").performClick()
        Assert.assertEquals(valueName, "Главная")
    }
}